Aloxaf / fzf-tab

Replace zsh's default completion selection menu with fzf!
MIT License
3.28k stars 94 forks source link

[Q] Is it possible to setup the following behavior without this patch? #362

Closed doronbehar closed 7 months ago

doronbehar commented 1 year ago

My desired behavior of this plugin is similar to the original behavior of fzf:

I didn't manage to play with all the settings and reach this behavior, so I ended up monkey-patching fzf-tab as follows:

diff --git i/lib/-ftb-fzf w/lib/-ftb-fzf
index 49cd277..9b204f9 100755
--- i/lib/-ftb-fzf
+++ w/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
+local binds=change:top,tab:toggle
 local fzf_command fzf_flags fzf_preview debug_command tmp switch_group fzf_pad fzf_min_height
 local ret=0

@@ -87,7 +87,7 @@ SHELL=$ZSH_NAME $fzf_command \
   --color=hl:$(( header_lines == 0 ? 188 : 255 )) \
   --cycle \
   --delimiter='\x00' \
-  --expect=$continuous_trigger,$print_query,$accept_line \
+  --expect=$continuous_trigger,$print_query,$accept_line,enter \
   --header-lines=$header_lines \
   --height=${FZF_TMUX_HEIGHT:=$(( min(max(lines, fzf_min_height), LINES / 3 * 2)  ))} \
   --layout=reverse \

With no settings other then zstyle ':fzf-tab:*' continuous-trigger "" in my .zshrc. Is it possible to get the behavior I desire without this patch?

Thanks for creating this wonderful plugin!

Aloxaf commented 7 months ago

The default keybinding can be overridden with zstyle ':fzf-tab:*' fzf-flags --bind "tab:toggle"

doronbehar commented 7 months ago

But @Aloxaf --bind and --expect is not the same thing. Also, with the config you suggested, pressing Enter doesn't put the selection to the line editor.

Aloxaf commented 7 months ago

Have you modified fzf's default key bindings elsewhere? According to fzf's documentation, enter is bound to the accept event by default.

doronbehar commented 7 months ago

Have you modified fzf's default key bindings elsewhere?

No.

According to fzf's documentation, enter is bound to the accept event by default.

I know.. Here's a screencast of what I'm experiencing:

https://asciinema.org/a/SZeA3qadPh5ElkeqeTAgHPTaY

I'm pressing enter in the ls fzf window, and the selections simply unselect themselves. Then I changed fzf-tab to a branch with the diff of the patch I wrote above, and the issue is fixed.

Aloxaf commented 7 months ago

Have you set FZF_DEFAULT_OPTS? It seems that you have something like enter:toggle in fzf options.

doronbehar commented 7 months ago

Have you set FZF_DEFAULT_OPTS?

Yes, to:

--layout=reverse --inline-info