14

When zsh shows you a menu of possible completions, I'd like it to let me use shift-tab to access previous completion entries--is there an option that controls what key is used to access previous completion entries?

And if so, what would I need to add to my ~/.zshrc file in order to set it up.

If it makes any difference, I currently can navigate through a completion-menu using the arrow-keys, but I dislike doing this since the arrow-keys feel out of place and awkward to use.

17

you want to bind the editor command reverse-menu-complete to the menuselect keymap.

bindkey -M menuselect '^[[Z' reverse-menu-complete

I am not sure how portable the escape sequence ^[[Z is, so you may want to check terminfo(5) to see if there is a way of using the $terminfo array to correctly bind it.

Note that the menuselect keymap is available after you load the zsh/complist module. If you've configured the completion system with compinstall, that module is generally automatically loaded the first time you complete something. To be able to add that binding to your ~/.zshrc, you need to load the module manually there first with:

zmodload zsh/complist
3
  • ^[[Z is shift-tab on my computer too, so no worries about it not being portable; thank you. :) Jul 30 '13 at 4:36
  • 3
    I get the following error when I invoke zsh after adding the bindkey line to my ~/.zshrc file: ~/.zshrc:bindkey:190: no such keymap `menuselect' Jul 30 '13 at 4:39
  • 3
    That would be "${terminfo[kcbt]}". Apr 11 '16 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.