1
0
Fork 0

use extra command parameter to do extra commands after main command

This commit is contained in:
Andrey Orst 2018-11-24 18:44:48 +03:00
parent 53f280dde8
commit 90f958819d
3 changed files with 8 additions and 5 deletions

View file

@ -26,6 +26,6 @@ define-command -hidden fzf-cd %{ evaluate-commands %sh{
*)
items_command=$kak_opt_fzf_cd_command ;;
esac
printf "%s\n" "fzf %{change-directory} %{$items_command} %{&& printf '%s\n' '; evaluate-commands fzf-cd'}"
printf "%s\n" "fzf %{change-directory} %{$items_command} %{} %{fzf-cd}"
}}

View file

@ -16,6 +16,6 @@ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
printf "%s\n" "info -title '$title' '$message'"
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" "fzf %{execute-keys} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content; echo 'gx')}"
printf "%s\n" "fzf %{execute-keys} %{(nl -b a -n ln $buffer_content} %{--reverse | cut -f 1; rm $buffer_content)} %{execute-keys gx}"
}}

View file

@ -63,10 +63,11 @@ Best used with mapping like:
" \
fzf-mode %{ try %{ evaluate-commands 'enter-user-mode fzf' } }
define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
define-command -hidden fzf -params 2..4 %{ evaluate-commands %sh{
callback=$1
items_command=$2
additional_flags=$3
extra_action=$4
tmux_height=$kak_opt_fzf_tmux_height
items_executable=$(printf "%s\n" "$items_command" | grep -o -E "[[:alpha:]]+" | head -1)
@ -139,14 +140,16 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
[ -n "$action" ] && printf "%s\n" "evaluate-commands -client $kak_client '$callback' '$action'" | kak -p $kak_session ;;
esac
kakoune_command() {
printf "%s\n" "evaluate-commands -client $kak_client '$wincmd $callback' '$1'"
printf "%s\n" "evaluate-commands -client $kak_client $wincmd $callback %{$1}"
}
while read item; do
kakoune_command "$item" | kak -p $kak_session
done
[ -n "$extra_action" ] && printf "%s\n" "evaluate-commands -client $kak_client $extra_action" | kak -p $kak_session
) < $tmp
fi
rm $tmp
) > /dev/null 2>&1 < /dev/null &
) &
# > /dev/null 2>&1 < /dev/null &
}}