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

Allow Tab and Shift-Tab to be disabled or reassigned #418

Closed
SephVelut opened this issue Feb 19, 2022 · 8 comments
Closed

Allow Tab and Shift-Tab to be disabled or reassigned #418

SephVelut opened this issue Feb 19, 2022 · 8 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SephVelut
Copy link

SephVelut commented Feb 19, 2022

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
@SephVelut SephVelut added the enhancement New feature or request label Feb 19, 2022
Repository owner locked and limited conversation to collaborators Feb 20, 2022
@marlonrichert marlonrichert converted this issue into a discussion Feb 20, 2022
Repository owner unlocked this conversation Feb 20, 2022
@marlonrichert marlonrichert changed the title Disable keys Allow Tab and Shift-Tab to be disabled or reassigned Feb 20, 2022
@marlonrichert marlonrichert reopened this Feb 20, 2022
@marlonrichert
Copy link
Owner

marlonrichert commented Feb 20, 2022

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.

@marlonrichert
Copy link
Owner

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

@lordzsolt
Copy link

@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?

@marlonrichert
Copy link
Owner

@lordzsolt Yes, that’s possible. Just set the following setting to yes:

zstyle ':autocomplete:*' insert-unambiguous no

@oldo
Copy link

oldo commented Aug 11, 2022

@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.

@marlonrichert
Copy link
Owner

@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.

@marlonrichert
Copy link
Owner

marlonrichert commented Aug 25, 2022

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.

@marlonrichert marlonrichert self-assigned this Aug 25, 2022
@marlonrichert marlonrichert removed their assignment Sep 27, 2022
@marlonrichert marlonrichert added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 27, 2022
@marlonrichert
Copy link
Owner

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! 🙂

@marlonrichert marlonrichert self-assigned this Oct 25, 2022
@marlonrichert marlonrichert removed their assignment Nov 15, 2022
marlonrichert added a commit that referenced this issue Feb 23, 2023
marlonrichert added a commit that referenced this issue Feb 27, 2023
marlonrichert added a commit that referenced this issue Feb 28, 2023
marlonrichert added a commit that referenced this issue Mar 21, 2023
marlonrichert added a commit that referenced this issue Apr 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants