Zsh completion, enabling shift-tab

autocompleteconfigurationzsh

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.

Best Answer

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