1
0
Fork 0

simplify fzf-yank-ring

This commit is contained in:
Andrey Orst 2019-04-08 11:28:11 +03:00
parent 78b1314fa9
commit c604547c09

View file

@ -20,8 +20,6 @@ hook global -once WinCreate .* %{
} }
} }
declare-option -hidden str fzf_yank_ring_result
define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{ define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{
yanks=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-yanks.XXXXXX) yanks=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-yanks.XXXXXX)
eval "set -- $kak_opt_yank_ring_history" eval "set -- $kak_opt_yank_ring_history"
@ -32,12 +30,10 @@ define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{
done done
message="Swap between items in yank-ring." message="Swap between items in yank-ring."
printf "%s\n" "fzf -kak-cmd %{set-option global fzf_yank_ring_result} -items-cmd %{cat $yanks} -post-action %{fzf-yank-ring-set-dquote}" printf "%s\n" "fzf -kak-cmd %{fzf-yank-ring-set-dquote} -items-cmd %{cat $yanks}"
}} }}
define-command fzf-yank-ring-set-dquote %{ define-command -hidden fzf-yank-ring-set-dquote -params 1 %{
set-register dquote %sh{ set-register dquote %sh{ printf "%s\n" "$1" | sed "s/␤/\n/g;" }
printf "%s\n" "$kak_opt_fzf_yank_ring_result" | sed "s/␤/\n/g;"
}
} }