Closed FunctionalHacker closed 2 weeks ago
It should be as straightforward as something like
fzf-tab-partial-and-complete() {
if [[ $LASTWIDGET = 'fzf-tab-partial-and-complete' ]]; then
fzf-tab-complete
else
zle complete-word
fi
}
zle -N fzf-tab-partial-and-complete
bindkey '^I' fzf-tab-partial-and-complete
but I'm not sure if it ideally should be a separate widget like the above, or a zstyle governing fzf-tab-complete
.
@rolandwalker That function doesn't work as intended when there is no common prefix:
I would love this as well... Is there any (custom) solution out there that will enable this behavior? Thanks!
TL;DR:
Use alt+enter
to print the partial match prefix.
After way too long, I notice this line (and later the wiki documentation for it):
126: -ftb-zstyle -s print-query print_query || print_query=alt-enter
Basically, a combination of print-query
=alt+enter
and query-string
=prefix
means fzf will auto-populate the query with the longest partial match prefix and pressing alt+enter
will autocomplete your command with the current query.
It's not perfect, it might add a space at the end or a slash if one of the matches is a folder. And obviously "1st tab auto-completes to the partial match prefix, 2nd tab opens fzf" would be much more desirable. But it does make life a bit easier without any modification to the existing code.
Relevant doco: https://github.com/Aloxaf/fzf-tab/wiki/Configuration#print-query
This seems to be the way the plugin functions now, possibly after #413 was merged
Okay this is a bit hard to explain, but here goes:
For example, when you have two files with a similar beginning, lets say
file1.txt
andfile2.txt
, most tab completion implementations I've seen works like this:At this point, when tab is pressed a second time, the completion plugin is invoked. I understand that this might be a personal preference, but I just thought to throw this idea out here.