Hi!
Is it somehow possible to use fzf instead of menu-complete i.e. fuzzy find in completions?
For example, you type git a, then hit
printf "add\nam\nannotate\napply\narchive\n" | fzf
I have exactly the same question about zsh. Lately I wanted to get my feet wet with zsh completions. I was writing a completion for a simple command:
ta [open|close] <tab_id...> [<tab_id...>]
What I want is to provide a list of tab_ids after open or close command. And not only provide, I'd like to conveniently select several of them using fzf. Here is my sketch:
#compdef ta
_ta() {
typeset -A opt_args
local context state line
_arguments \
"1:command:(open close)" \
"*:tabs:->tabs" \
&& return 0
case "$state" in
tabs)
case "$words[2]" in
open)
echo "OPEN OR CLOSE"
__tabs
;;
esac
;;
esac
return 1
}
__tabs() {
_values 'tabs' tfirst tsecond tthird
# compadd "$@" $(__get_tabs)
# _fzf_complete < <(
# echo "tab_first1\ntab_second2"
# )
}
_ta "$@"
The great disappointment here is that when in __tabs I return multiple values, menu-select chimes in and allows me to select several items. Even though I can find the tab_ids and select those which I need using M-a (accept-and-hold), fzf could be much better here.
Alternatively I could employ fzf completion framework as described in the Wiki, but I can't see how I can easily use it inside of my zsh's compsys high-level completion functions.
Ideally, I wish there were a command similar to _values that would accept a list of candidates, run fzf, and accepts everything that fzf returned into the command line.
@junegunn Is there a way to do anything like that? Maybe a way to provide a widget similar to menu-select but powered by fzf. Just to be clear, I know that fzf scripts already do that, but as far as I understand, they are using low-level zle commands, while I'd like to use fzf inside of more high-level compsys commands.
I also noticed that that echo (and __tabs) is called four times, thus if I naively call fzf in the commented code fragment, this isn't gonna work. Do you have any idea why is __tabs called four times?
Probably similar question asked in zaw: https://github.com/zsh-users/zaw/issues/64
i'm also interested in this - i'd like to continue using tab for completion as normal (pressing tab will insert the longest common substring without prompting), but if i press tab again, instead of showing the normal menu of possible completions and cycling through them, i'd like it to just open fzf instead.
Have you tried to use zstyle ':completion:*' menu select=0 interactive, it's not fuzzy, but it can help.

I have been developing zsh-completion-engine using fzf.
I hope that it will realize the completion discussed here in a general-purpose way.
https://github.com/relastle/pmy
If base-version of this seems to be highly demanded, i will consider to develop it!

Hey not quite a completion engine but I鈥檝e been working on a bash ide based on fzf Ctrl-E opens a list of all command with preview bing man page and inserts selected into the read line alt-o pulls up flags with preview being context within a line or two in the man page then inserts them to the cmd line https://GitHub.com/rayiik/Man-fzf-scripts still a worm in progress but few free to check it out /use it throw me some suggestions
Most helpful comment
I have been developing zsh-completion-engine using fzf.
I hope that it will realize the completion discussed here in a general-purpose way.
https://github.com/relastle/pmy
If base-version of this seems to be highly demanded, i will consider to develop it!