1
0
Fork 0

fix yank ring

This commit is contained in:
Andrey Orst 2019-04-08 11:24:07 +03:00
parent 58e065669f
commit bae554f28e

View file

@ -11,19 +11,33 @@
# ╰─────────────────────────────────────╯
try %{ declare-user-mode fzf }
map global fzf -docstring "open yank-ring" 'y' '<esc>: fzf-yank-ring<ret>'
# this will fail if yank-ring.kak isn't installed
hook global -once WinCreate .* %{
try %{
set-option -add global yank_ring_history
map global fzf -docstring "open yank-ring" 'y' '<esc>: fzf-yank-ring<ret>'
}
}
declare-option -hidden str fzf_yank_ring_result
define-command -hidden fzf-yank-ring %{ evaluate-commands %sh{
yanks=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-yanks.XXXXXX)
eval "set -- $kak_opt_yank_ring_history"
while [ $# -gt 0 ]; do
item=$(printf "%s" "$1" | awk 1 ORS='␤')
item=$(printf "%s" "$1" | sed "s/^'//;s/'$//" | awk 1 ORS='␤')
printf "%s\n" "$item" >> $yanks
shift
done
message="Swap between yanks."
printf "%s\n" "fzf -kak-cmd %{set-register dquote} -items-cmd %{cat $yanks} -filter %{sed 's/␤/\\\\n/g;s/^.//;s/.\\\n$//'}"
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}"
}}
define-command fzf-yank-ring-set-dquote %{
set-register dquote %sh{
printf "%s\n" "$kak_opt_fzf_yank_ring_result" | sed "s/␤/\n/g;"
}
}