remove fzf-tmux dependency
This commit is contained in:
parent
33ac8ff351
commit
9362723bde
1 changed files with 17 additions and 12 deletions
29
rc/fzf.kak
29
rc/fzf.kak
|
@ -93,7 +93,7 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
highlighter=$kak_opt_fzf_highlighter ;;
|
highlighter=$kak_opt_fzf_highlighter ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ ! -z "${kak_client_env_TMUX}" ]; then
|
if [ -n "$kak_client_env_TMUX" ]; then
|
||||||
preview_pos="pos=right:$kak_opt_fzf_preview_width;"
|
preview_pos="pos=right:$kak_opt_fzf_preview_width;"
|
||||||
tmux_height=$kak_opt_fzf_tmux_height_file_preview
|
tmux_height=$kak_opt_fzf_tmux_height_file_preview
|
||||||
else
|
else
|
||||||
|
@ -103,28 +103,34 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
additional_flags="--preview '($highlighter || cat {}) 2>/dev/null | head -n $kak_opt_fzf_preview_lines' --preview-window=\$pos $additional_flags"
|
additional_flags="--preview '($highlighter || cat {}) 2>/dev/null | head -n $kak_opt_fzf_preview_lines' --preview-window=\$pos $additional_flags"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp ${TMPDIR:-/tmp}/kak-fzf.XXXXXX)
|
tmp=$(mktemp ${TMPDIR:-/tmp}/kak-fzf-tmp.XXXXXX)
|
||||||
shell=$(command -v sh)
|
fzfcmd=$(mktemp ${TMPDIR:-/tmp}/kak-fzfcmd.XXXXXX)
|
||||||
if [ ! -z "${kak_client_env_TMUX}" ]; then
|
printf "%s\n" "cd $PWD && $preview_pos $items_command | SHELL=$(command -v sh) fzf $additional_flags > $tmp" > $fzfcmd
|
||||||
cmd="$preview_pos $items_command | fzf-tmux -d $tmux_height $additional_flags > $tmp"
|
chmod 755 $fzfcmd
|
||||||
elif [ ! -z "${kak_opt_termcmd}" ]; then
|
|
||||||
fzfcmd=$(mktemp ${TMPDIR:-/tmp}/kak-fzfcmd.XXXXXX)
|
if [ -n "$kak_client_env_TMUX" ]; then
|
||||||
chmod 755 $fzfcmd
|
[ -n "${tmux_height%%*%}" ] && measure="-p" || measure="-p"
|
||||||
printf "%s\n" "cd $PWD && $preview_pos $items_command | SHELL=$shell fzf $additional_flags > $tmp" > $fzfcmd
|
cmd="command tmux split-window $measure ${tmux_height%%%*} 'sh -c $fzfcmd; rm $fzfcmd'"
|
||||||
cmd="$kak_opt_termcmd 'sh -c $fzfcmd'"
|
elif [ -n "$kak_opt_termcmd" ]; then
|
||||||
|
cmd="$kak_opt_termcmd 'sh -c $fzfcmd; rm $fzfcmd'"
|
||||||
else
|
else
|
||||||
printf "%s\n" "fail %{termcmd option is not set}"
|
printf "%s\n" "fail %{termcmd option is not set}"
|
||||||
|
rm $fzfcmd
|
||||||
|
rm $tmp
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
|
while [ -e $fzfcmd ]; do
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
if [ -s $tmp ]; then
|
if [ -s $tmp ]; then
|
||||||
(
|
(
|
||||||
read action
|
read action
|
||||||
case $action in
|
case $action in
|
||||||
ctrl-w)
|
ctrl-w)
|
||||||
[ ! -z "${kak_client_env_TMUX}" ] && wincmd="tmux-new-window" || wincmd="x11-new" ;;
|
[ -n "$kak_client_env_TMUX" ] && wincmd="tmux-new-window" || wincmd="x11-new" ;;
|
||||||
ctrl-s)
|
ctrl-s)
|
||||||
wincmd="tmux-new-vertical" ;;
|
wincmd="tmux-new-vertical" ;;
|
||||||
ctrl-v)
|
ctrl-v)
|
||||||
|
@ -141,7 +147,6 @@ define-command -hidden fzf -params 2..3 %{ evaluate-commands %sh{
|
||||||
) < $tmp
|
) < $tmp
|
||||||
fi
|
fi
|
||||||
rm $tmp
|
rm $tmp
|
||||||
[ -n "$fzfcmd" ] && rm $fzfcmd
|
|
||||||
) > /dev/null 2>&1 < /dev/null &
|
) > /dev/null 2>&1 < /dev/null &
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue