Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible not to display the FZF until the common part is completed? #29

Open
bimlas opened this issue Jan 6, 2021 · 3 comments
Open

Comments

@bimlas
Copy link

bimlas commented Jan 6, 2021

For example, if I press tab after the text apti, ZSH without fzf-tab-completion will complete the command to aptitude, which is already in my muscle memory. Using the plugin instead will show all the commands starting with apti and I don't like this.

Is it possible not to display FZF until the common part is completed, only if I press tab a second time (apti -> tab -> aptitude -> tab -> FZF completion)?

@przepompownia
Copy link

I agree: this tool should non-interactively complete the common leading part and wait for complete the rest if there are more than one items.

@lincheney
Copy link
Owner

I'm willing to take a PR to optionally enable this.
The difficulty you are going to run into is that fzf loads as soon as there are >=2 matches available even before all matches are loaded (this lets you complete or cancel without having to wait until the very end in case the completion is slow), whereas to compute a common prefix you need all matches to have loaded, so logic would be quite different.

@crsohr
Copy link

crsohr commented May 8, 2021

I had the same issue.

Maybe not the best workaround, what I did is trigger fzf completion only when the character before the cursor is not a letter or a digit.

This way if I do:

$ apti<TAB>

It completes aptitude without using fzf, and if I do any of those:

$ kill <TAB>
$ cd /<TAB>

I still get the benefit of fzf completion.

To do so, I added these lines in my ~/.zshrc, after the moment I loaded fzf-zsh-completions.sh:

function smart_completion() {
  if [[ "$LBUFFER" =~ [a-zA-Z0-9]$ ]]; then
    _main_complete
  else
    fzf_completion
  fi
}
zle -C fzf_completion complete-word smart_completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants