Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Completion failing on Ubuntu 20.04 (fzf version <= 0.20.0)

fabian-thomas opened this issue · comments

See below for the final solution: #391 (comment)

The problem

Ubuntu 20.04 does ship fzf 0.20.0 which does not yet support the backward-delete-char/eof binding, therefore fzf-tab fails to query completion from fzf.

Here is the relevant debug output (bindkey "^I" fzf-tab-debug):

+-ftb-fzf:83> SHELL=zsh fzf --ansi '--bind=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof,bspace:down' '--bind=F1:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab/lib/ftb-switch-group 139498 0 /tmp/zsh-fzf-tab-fthomas -1),F2:reload(/usr/bin/zsh -f /home/fth>
unknown action: backward-delete-char/eof
  +-ftb-fzf:100> ret=2
  +-ftb-fzf:102> ((  ! use_tmux_popup  ))
  +-ftb-fzf:103> echoti civis
  +-ftb-fzf:104> echoti cuu1
  +-ftb-fzf:107> rm /tmp/zsh-fzf-tab-fthomas/compcap.139498 /tmp/zsh-fzf-tab-fthomas/completions.139498 /tmp/zsh-fzf-tab-fthomas/ftb_preview_init.139498 /tmp/zsh-fzf-tab-fthomas/groups.139498
  +-ftb-fzf:108> return 2

Running the printed fzf command directly gives:

# SHELL=zsh fzf --ansi '--bind=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof' '--bind=F1:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab/lib/ftb-switch-group 138359 0 /tmp/zsh-fzf-tab-fthomas -1),F2:reload(/usr/bin/zsh -f /home/fthomas/fzf-tab'
unknown action: backward-delete-char/eof

Temporary fix

This can be fixed by editing lib/-ftb-fzf and replacing the line that sets the binds from:

local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof

to

local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char

(thereby just stripping the /eof)

Potential permanent fixes

Three come to my mind:

  • Just keep it as is and only support newer fzf versions. Then this issue can be closed and should help people that have the same problem.
  • Set binds depending on fzf version. Should be doable in 2-4 lines of code. Just check fzf version and set binds depending on that.
  • Provide an option to overwrite binds completely, since from the code it seems like there is no way to do that.

Thanks for the temporary fix!

If it is useful to anyone, the temporary fix can be written as a git patch, and applied with git apply <patch_file>, where <patch_file> has the following contents:

diff --git a/lib/-ftb-fzf b/lib/-ftb-fzf
index 2cb4228..b1158cf 100755
--- a/lib/-ftb-fzf
+++ b/lib/-ftb-fzf
@@ -28,7 +28,7 @@ if (( \$+ctxt[realdir] )); then
 fi
 $(typeset -p words)
 "
-local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char/eof,ctrl-h:backward-delete-char/eof
+local binds=tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char
 local fzf_command fzf_flags fzf_preview debug_command tmp switch_group fzf_pad fzf_min_height
 local ret=0

The final fix for zsh is the following in your zshrc:

zstyle ':fzf-tab:*' fzf-bindings-default 'tab:down,btab:up,change:top,ctrl-space:toggle,bspace:backward-delete-char,ctrl-h:backward-delete-char'