new filter flag, which acts like final pipe after fzf command
This commit is contained in:
parent
900a16e344
commit
f42cbcb86f
2 changed files with 10 additions and 9 deletions
11
rc/fzf.kak
11
rc/fzf.kak
|
@ -105,19 +105,20 @@ Switches:
|
||||||
-kak-cmd <command>: A Kakoune cmd that is applied to fzf resulting value.
|
-kak-cmd <command>: A Kakoune cmd that is applied to fzf resulting value.
|
||||||
-items-cmd <items command>: A command that is used to provide list of values to fzf.
|
-items-cmd <items command>: A command that is used to provide list of values to fzf.
|
||||||
-fzf-args <args>: Additional flags for fzf program
|
-fzf-args <args>: Additional flags for fzf program
|
||||||
-post-action <commands>: Extra commands that are preformed after `-kak-cmd' command.
|
|
||||||
-preview-cmd: a preview command
|
-preview-cmd: a preview command
|
||||||
-preview: should fzf window include preview" \
|
-preview: should fzf window include preview
|
||||||
|
-filter <commands>: A pipe which will be applied to result provided by fzf
|
||||||
|
-post-action <commands>: Extra commands that are preformed after `-kak-cmd' command." \
|
||||||
fzf -shell-script-completion %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-action\n"} -params .. %{ evaluate-commands %sh{
|
fzf -shell-script-completion %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-action\n"} -params .. %{ evaluate-commands %sh{
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-kak-cmd) shift; kakoune_cmd="$1" ;;
|
-kak-cmd) shift; kakoune_cmd="$1" ;;
|
||||||
-items-cmd) shift; items_cmd="$1" ;;
|
-items-cmd) shift; items_cmd="$1" ;;
|
||||||
-fzf-args) shift; fzf_args="$1" ;;
|
-fzf-args) shift; fzf_args="$1" ;;
|
||||||
-post-action) shift; post_action="$1" ;;
|
|
||||||
-preview-cmd) shift; preview_cmd="$1" ;;
|
-preview-cmd) shift; preview_cmd="$1" ;;
|
||||||
-preview) preview="true" ;;
|
-preview) preview="true" ;;
|
||||||
*) ;;
|
-filter) shift; filter="| $1" ;;
|
||||||
|
-post-action) shift; post_action="$1" ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
@ -149,7 +150,7 @@ fzf -shell-script-completion %{echo "-kak-cmd\n-items-cmd\n-fzf-args\n-post-acti
|
||||||
result="${fzf_tmp}/result"
|
result="${fzf_tmp}/result"
|
||||||
|
|
||||||
# compose entire fzf command with all args into single file which will be executed later
|
# compose entire fzf command with all args into single file which will be executed later
|
||||||
printf "%s\n" "cd \"${PWD}\" && ${preview_position} ${items_cmd} | SHELL=$(command -v sh) ${kak_opt_fzf_implementation} ${fzf_args} ${preview_cmd} > ${result}; rm ${fzfcmd}" > ${fzfcmd}
|
printf "%s\n" "cd \"${PWD}\" && ${preview_position} ${items_cmd} | SHELL=$(command -v sh) ${kak_opt_fzf_implementation} ${fzf_args} ${preview_cmd} ${filter} > ${result}; rm ${fzfcmd}" > ${fzfcmd}
|
||||||
chmod 755 ${fzfcmd}
|
chmod 755 ${fzfcmd}
|
||||||
|
|
||||||
if [ -n "${kak_client_env_TMUX}" ]; then
|
if [ -n "${kak_client_env_TMUX}" ]; then
|
||||||
|
|
|
@ -17,6 +17,6 @@ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
|
||||||
printf "%s\n" "info -title '$title' '$message'"
|
printf "%s\n" "info -title '$title' '$message'"
|
||||||
buffer_content="$(mktemp ${TMPDIR:-/tmp}/fzf-buff-${kak_buffile##*/}.XXXXXX)"
|
buffer_content="$(mktemp ${TMPDIR:-/tmp}/fzf-buff-${kak_buffile##*/}.XXXXXX)"
|
||||||
printf "%s\n" "execute-keys -draft %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
|
printf "%s\n" "execute-keys -draft %{%<a-|>cat<space>><space>$buffer_content<ret>;}"
|
||||||
printf "%s\n" "fzf -kak-cmd %{execute-keys} -items-cmd %{(nl -b a -n ln $buffer_content; rm $buffer_content)} -fzf-args %{--reverse | cut -f 1} -post-action %{execute-keys gx}"
|
printf "%s\n" "fzf -kak-cmd %{execute-keys} -items-cmd %{(nl -b a -n ln $buffer_content; rm $buffer_content)} -fzf-args %{--reverse} -filter %{cut -f 1} -post-action %{execute-keys gx}"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue