From dc6d0a504ef43511642448c1d7447855b8f17f54 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Fri, 13 Mar 2020 19:01:19 +0300 Subject: [PATCH] use selection as default search query --- rc/fzf.kak | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index fe5730c..6ec0229 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -137,6 +137,10 @@ Switches: fzf -params .. %{ evaluate-commands %sh{ fzf_impl="${kak_opt_fzf_implementation}" + if [ $(printf "%s" "${kak_selection}" | wc -m) -gt 1 ]; then + default_query="-i -q ${kak_selection}" + fi + while [ $# -gt 0 ]; do case $1 in (-kak-cmd) shift; kakoune_cmd="$1" ;; @@ -191,7 +195,7 @@ fzf -params .. %{ evaluate-commands %sh{ printf "%s\n" "SHELL=${shell_path}" fi # compose entire fzf command with all args into single file which will be executed later - printf "%s\n" "cd \"${PWD}\" && ${preview_position} ${items_cmd} ${fzf_impl} ${fzf_args} ${preview_cmd} ${filter} > ${result}" + printf "%s\n" "cd \"${PWD}\" && ${preview_position} ${items_cmd} ${fzf_impl} ${default_query} ${fzf_args} ${preview_cmd} ${filter} > ${result}" printf "%s\n" "rm ${fzfcmd}" ) >> ${fzfcmd} chmod 755 ${fzfcmd}