diff --git a/rc/fzf-modules/sk-grep.kak b/rc/fzf-modules/sk-grep.kak index 4e2cffb..c2cf1cb 100644 --- a/rc/fzf-modules/sk-grep.kak +++ b/rc/fzf-modules/sk-grep.kak @@ -39,12 +39,12 @@ define-command -hidden fzf-sk-interactive-grep %{ evaluate-commands %sh{ printf "%s\n" "info -title '${title}' '${message}${tmux_keybindings}'" [ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect ctrl-v --expect ctrl-s" impl=$kak_opt_fzf_implementation - printf "%s\n" "set-option global fzf_implementation \"sk -i -c '$kak_opt_fzf_sk_grep_command {}'\" + printf "%s\n" "set-option global fzf_implementation %{sk -i -c '$kak_opt_fzf_sk_grep_command {}'} fzf -kak-cmd %{fzf-sk-grep-handler} -items-cmd %{echo >/dev/null 2>&1} -fzf-args %{--expect ctrl-w $additional_flags} - set-option global fzf_implementation $impl" + set-option global fzf_implementation %{${impl}}" }} -define-command fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{ +define-command -hidden fzf-sk-grep-handler -params 1 %{ evaluate-commands %sh{ printf "%s\n" "$1" | awk '{ file = $0; sub(/:.*/, "", file); gsub("&", "&&", file); line = $0; sub(/[^:]+:/, "", line); sub(/:.*/, "", line) diff --git a/rc/fzf.kak b/rc/fzf.kak index 2247589..a2282e7 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -119,14 +119,14 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti shift done - if [ "$preview" = "true" ]; then + if [ "${preview}" = "true" ]; then if [ -n "${kak_client_env_TMUX}" ]; then - [ -z "${kakoune_cmd##edit*}" ] && tmux_height="$kak_opt_fzf_file_preview_tmux_height" + [ -z "${kakoune_cmd##edit*}" ] && tmux_height="${kak_opt_fzf_file_preview_tmux_height}" preview_position="pos=right:${kak_opt_fzf_preview_width};" else preview_position="sleep 0.1; [ \$(tput cols) -gt \$(expr \$(tput lines) \* 2) ] && pos=right:${kak_opt_fzf_preview_width} || pos=top:${kak_opt_fzf_preview_height};" fi - if [ ${kak_opt_fzf_preview} = "true" ] && [ -z "$preview_cmd" ]; then + if [ ${kak_opt_fzf_preview} = "true" ] && [ -z "${preview_cmd}" ]; then case ${kak_opt_fzf_highlight_cmd} in bat) highlight_cmd="bat --color=always --style=plain {}" ;; coderay) highlight_cmd="coderay {}" ;; @@ -145,7 +145,7 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti chmod 755 ${fzfcmd} if [ -n "${kak_client_env_TMUX}" ]; then - [ -z "$tmux_height" ] && tmux_height=$kak_opt_fzf_tmux_height + [ -z "${tmux_height}" ] && tmux_height=${kak_opt_fzf_tmux_height} [ -n "${tmux_height%%*%}" ] && measure="-l" || measure="-p" cmd="nop %sh{ command tmux split-window ${measure} ${tmux_height%%%*} 'sh -c ${fzfcmd}' }" else @@ -154,31 +154,28 @@ fzf -shell-script-candidates %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti ( printf "%s\n" "${cmd}" | kak -p ${kak_session} - while [ -e $fzfcmd ]; do + while [ -e ${fzfcmd} ]; do sleep 0.1 done - if [ -s $result ]; then + if [ -s ${result} ]; then ( read action - case $action in + 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 + 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 - kakoune_command() { - printf "%s\n" "evaluate-commands -client $kak_client $wincmd %{$kakoune_cmd %{$1}}" - [ -n "$post_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $post_action" - } while read item; do - kakoune_command "$item" | kak -p $kak_session + 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} done - ) < $result + ) < ${result} fi - rm $fzf_tmp + rm ${fzf_tmp} ) > /dev/null 2>&1 < /dev/null & }}