From b8bcbc33c73febdbe74237a81e4721eca032b5e1 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Wed, 27 Mar 2019 09:27:51 +0300 Subject: [PATCH] further simplifications of main script --- rc/fzf.kak | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index 31570ff..e70ac60 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -157,28 +157,28 @@ fzf -shell-script-completion %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti cmd="terminal %{${fzfcmd}}" fi - ( - printf "%s\n" "${cmd}" | kak -p ${kak_session} - while [ -e ${fzfcmd} ]; do + printf "%s\n" "${cmd}" + + ( while [ -e ${fzfcmd} ]; do sleep 0.1 done if [ -s ${result} ]; then ( - read action - case ${action} in - ctrl-w) wincmd="fzf-window" ;; - ctrl-s) wincmd="fzf-vertical" ;; - ctrl-v) wincmd="fzf-horizontal" ;; - *) if [ -n "${action}" ]; then - printf "%s\n" "evaluate-commands -client ${kak_client} '${kakoune_cmd}' '${action}'" | kak -p ${kak_session} - [ -n "${post_action}" ] && printf "%s\n" "evaluate-commands -client ${kak_client} ${post_action}" | kak -p ${kak_session} - fi ;; - esac - while read item; do - printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}" | kak -p ${kak_session} - [ -n "${post_action}" ] && printf "%s\n" "evaluate-commands -client ${kak_client} ${post_action}" | kak -p ${kak_session} + while read line; do + case ${line} in + ctrl-w) wincmd="fzf-window" ;; + ctrl-s) wincmd="fzf-vertical" ;; + ctrl-v) wincmd="fzf-horizontal" ;; + *) item=${line} ;; + esac + if [ -n "${item}" ]; then + printf "%s\n" "evaluate-commands -client ${kak_client} ${wincmd} %{${kakoune_cmd} %{${item}}}" + fi done - ) < ${result} + if [ -n "${post_action}" ]; then + printf "%s\n" "evaluate-commands -client ${kak_client} %{${post_action}}" + fi + ) < ${result} | kak -p ${kak_session} fi rm -rf ${fzf_tmp} ) > /dev/null 2>&1 < /dev/null &