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

[FR] Map TAB to "accept" when there is only one item #202

Closed
jmgq opened this issue Mar 9, 2021 · 3 comments
Closed

[FR] Map TAB to "accept" when there is only one item #202

jmgq opened this issue Mar 9, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@jmgq
Copy link

jmgq commented Mar 9, 2021

This feature is better described with an example:

Let's say that if you go to your home folder and type less .zsh and then press TAB, you will be presented with a list with three options:

  • .zshrc
  • .zshenv
  • .zsh_hist

Every time you press TAB, it will highlight the next item, as you would expect. However, if you type the letter r, the list of suggestions will be filtered, and the only available option will be .zshrc.

In this case, when there is just one option available, I think that if you press TAB again, it would be good if .zshrc was automatically selected, since it's the only available option. But instead, nothing happens until you press ENTER, in which case the option is selected.

After checking the fzf manual, I noticed that there is a flag called --select-1 under the "Scripting" section, and its description reads "Automatically select the only match". I have tried the following configurations, with no success:

zstyle ':fzf-tab:*' fzf-flags --select-1
zstyle ':fzf-tab:*' extra-opts '--select-1'
export FZF_DEFAULT_OPTS="--select-1"

I have also tried zstyle ':fzf-tab:*' fzf-bindings 'tab:accept', but that of course removes the cycling with TAB feature (you'll have to use the arrow keys to navigate through the options).

@jmgq jmgq added the enhancement New feature or request label Mar 9, 2021
@Aloxaf
Copy link
Owner

Aloxaf commented Mar 10, 2021

--select-1 only works on the initial input, like echo a | fzf --select-1.

I think there is no way to implement it.

@jmgq
Copy link
Author

jmgq commented Mar 10, 2021

Fair enough, thanks for looking into it anyway. I wish I could help or suggest something, but I wouldn't know where to start, so please feel free to close this issue if it looks like it cannot be done.

@Aloxaf Aloxaf closed this as completed Mar 10, 2021
@Andrej-Marsic
Copy link

fzf has the event one. So this could be possible.

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

No branches or pull requests

3 participants