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

Single tab triggers completion rather than double tab #22

Open
gene-pavlovsky opened this issue Nov 19, 2019 · 2 comments
Open

Single tab triggers completion rather than double tab #22

gene-pavlovsky opened this issue Nov 19, 2019 · 2 comments

Comments

@gene-pavlovsky
Copy link

Perhaps this is by design, in which case would be nice to hear the motivation behind that. It is mentioned in the README that the hotkey is .
When not using fzf-obc, one is used to complete the currently typed text, while a shows the whole list of available completions. With fzf-obc, habitually typing ls /<TAB><TAB> results in the completion list showing due to the first , and then the first item in the list being selected due to the second one. Of course a user can re-train their behavior if necessary, but I wonder if that is useful, perhaps it would be better to keep the traditional way?

@rockandska
Copy link
Owner

Hello,

It is not really by 'design' but more due to the way how bash completion works.
In original completion, the first <TAB> add results to $COMPREPLY, then, the second hit display a list or directly the result if there is only one result.
The display of the results is done by readline completion at a lower level and never found a way to only act at the second <TAB>.
If i was a found a way to do it, i never had to create a wrapper for all complete function but just override readline-complete to trigger fzf over the results.

Even without this, i always found weird to have to hit twice <TAB> to display the completion results since hitting <TAB> is cleary to trigger the completion but could fully understand what you describe. Despite that, i'm not close to add this capability if i found someday a way to only override readline completion.

Since i don't have a tweak for this now, you could change the key used to select a result in fzf. This way, hitting <TAB> twice will not have any undesirable behavior.

as an example, use <SPACE> to validate the results:

$ FZF_OBC_BINDINGS='--bind space:accept'
$ FZF_OBC_GLOBS_OPTS='-m  --bind space:accept'

@gene-pavlovsky
Copy link
Author

I don't see why is it weird to hit twice to display results.
If you actually know what you're completing, normally you can just use once, and you don't really need to see the list of results, since the correct entry will be completed.
If there are 5 photos with names photo1.jpg, photo2.jpg etc, you can type p 3 to get photo3.jpg. Now if there's also an unexpected photo30.jpg in this dir, the second does nothing, you then tap once again to see the list, and understand why it didn't complete as expected. But in many cases there's no need to show the completions list.

But I understand that it might be difficult to implement technically if bash completion doesn't provide enough flexibility. I will think about changing fzf's default key binding, although I'm quite used to it so the option doesn't sound very attractive :)

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

2 participants