Allow Tab and Shift-Tab to be disabled or reassigned
I'm using zsh-autosuggestions and it allows me to use its completion with tab and shift+tab. I like it's completion. But I also want to use autocomplete. The problem is that this plugin also uses tab and shift+tab. How can I disable those two keys for autocomplete?
I tried
zstyle ':autocomplete:*' bindkey no
and
zstyle ':autocomplete:*' bind-key no
It's currently not possible to disable or reassign Zsh Autocomplete's Tab and Shift-Tab functionality. I'll have to think about what would be the best way to make this possible.
As a workaround, you can add the following to your .zshrc file, after sourcing Zsh Autocomplete:
add-zsh-hook precmd bind-tab
bind-tab() {
bindkey '\t' <your preferred tab widget>
bindkey $terminfo[kcbt] <your preferred shift-tab widget>
}
@SephVelut @LoLei @Alex-duzhichao @crushingCodes @AndreCascais @mjrussell
@marlonrichert A bit of a followup question/request, I would also like to disable or tweak the Tab behavior.
If you have the following directories:
foo1
foo2
foo3
The moment I write cd fo and press Tab, I want it to autocomplete cd foo rather than cd foo1.
Is there any possibility for that?
@lordzsolt Yes, that’s possible. Just set the following setting to yes:
https://github.com/marlonrichert/zsh-autocomplete/blob/5b0073d8ffde20498c820f94ddc62b7f3f54cfc7/.zshrc#L37
@marlonrichert I also am trying to achieve the same thing as @lordzsolt however your suggestion of setting insert-unambiguous to yes is not making any difference for me.
@oldo Works for me:
% cd $(mktemp -d)
> .zshrc <<EOF
PS1='%# ' PS2= RPS2='%^'; setopt transientrprompt interactivecomments
source /path/to/zsh-autocomplete.plugin.zsh
zstyle ':autocomplete:*' insert-unambiguous yes
EOF
env -i HOME=$PWD PATH=$PATH TERM=$TERM ${TERMINFO:+TERMINFO=$TERMINFO} zsh -d
Please use the above to create a reproducible test case. If I can't reproduce it, then I can't fix it.
I just realized what would be a good way to give more control over Tab and Shift-Tab assignment: Just don't override the current keybinding.
I'll add this to my TODO list.
I haven't found the time to implement this yet. It's not complex, though. The following should be done:
- [ ] If the currently supported zstyle for this has been set, use that (for backwards compatibility.
- [ ] Remove the zstyle from the docs.
- [ ] If it hasn't been set, then don't override the current keybindings.
- [ ] Add this to the documentation.
Pull requests welcome! 🙂