From 53f280dde80017fe982dfff9f1f909226363a590 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Sat, 24 Nov 2018 17:29:44 +0300 Subject: [PATCH] simplify buffer, remove deleting buffers --- rc/fzf-modules/fzf-buffer.kak | 45 ++--------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/rc/fzf-modules/fzf-buffer.kak b/rc/fzf-modules/fzf-buffer.kak index 0d65016..c3064d4 100644 --- a/rc/fzf-modules/fzf-buffer.kak +++ b/rc/fzf-modules/fzf-buffer.kak @@ -11,48 +11,7 @@ map global fzf -docstring "open buffer" 'b' ': fzf-buffer' define-command -hidden fzf-buffer %{ evaluate-commands %sh{ - echo "info -title 'fzf buffer' 'Set buffer to edit in current client. -: delete selected buffer'" - - tmux_height=$kak_opt_fzf_tmux_height + printf "%s\n" "info -title %{fzf buffer} %{Set buffer to edit in current client.}" buffers=$(printf "%s\n" "$kak_buflist" | sed "s/^'//;s/'$//;s/' '/\n/g") - - tmp=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-tmp.XXXXXX) - fzfcmd=$(mktemp ${TMPDIR:-/tmp}/kak-fzfcmd.XXXXXX) - printf "%s\n" "printf '%s\n' '$buffers' | SHELL=$(command -v sh) fzf --expect ctrl-d > $tmp" > $fzfcmd - chmod 755 $fzfcmd - - if [ -n "$kak_client_env_TMUX" ]; then - [ -n "${tmux_height%%*%}" ] && measure="-p" || measure="-p" - cmd="command tmux split-window $measure ${tmux_height%%%*} 'sh -c $fzfcmd; rm $fzfcmd'" - elif [ -n "$kak_opt_termcmd" ]; then - cmd="$kak_opt_termcmd 'sh -c $fzfcmd; rm $fzfcmd'" - else - printf "%s\n" "fail %{termcmd option is not set}" - rm $fzfcmd - rm $tmp - exit - fi - - ( - eval "$cmd" - while [ -e $fzfcmd ]; do - sleep 0.1 - done - if [ -s $tmp ]; then - ( - read action - read buf - if [ "$action" = "ctrl-d" ]; then - printf "%s\n" "evaluate-commands -client $kak_client delete-buffer $buf" | kak -p $kak_session - printf "%s\n" "evaluate-commands -client $kak_client fzf-buffer" | kak -p $kak_session - else - printf "%s\n" "evaluate-commands -client $kak_client buffer $buf" | kak -p $kak_session - fi - ) < $tmp - else - printf "%s\n" "evaluate-commands -client $kak_client buffer $kak_bufname" | kak -p $kak_session - fi - rm $tmp - ) > /dev/null 2>&1 < /dev/null & + printf "%s\n" "fzf %{buffer} %{printf \"%s\n\" \"$buffers\"}" }}