lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

Possible to backspace prompt #93

Closed clinta closed 6 months ago

clinta commented 6 months ago

If I run ls abc<tab> the abc portion of the search is permanent, I cannot edit it to broaden my search without canceling the search first. Is there any way to adjust this behavior?

d-enk commented 6 months ago

no, you can't do that at least because for a different input there will be a different stream of lines for fzf

lincheney commented 6 months ago

Hi

no, you can't do that at least because for a different input there will be a different stream of lines for fzf

It's exactly this. Since the completion functions (not fzf-tab-completion) give you different matches depending on what you have already entered.

As an example, if you do ls <tab> it will show you only files whereas ls -<tab> will show you only options, they are not subsets of each other. You must re-trigger the completion to go from one to the other.

clinta commented 6 months ago

Is it possible with a keybind perhaps, when backspace is entered and the search query is empty, re-run tab completion with a new prompt less the last character?

lincheney commented 6 months ago

If you are using bash, then unfortunately keybinds cannot currently re-run tab completion.

If you are using zsh you may be able to get something working using https://github.com/lincheney/fzf-tab-completion?tab=readme-ov-file#specifying-keybindings. Essentially, if you can make a binding key:function where pressing key will stop fzf and invoke the given shell function. You can try write a function like:

fzf-completion-backspace-and-retry() {
    # modify BUFFER or LBUFFER or something
    LBUFFER=...
    repeat-fzf-completion
}

However, afaict there is no way to happen only if the search query is empty (ie this keybind will end up always run this function).