2

In my .zshrc I have

zstyle ':completion:*' menu select=20

This way when I hit Tab twice, I receive a menu of completions (assuming there are at least 20 to choose from). I can then navigate it using Up and Down keys. I would expect PgUp and PgDown to scroll up/down a page, but that is not the default behavior.

A natural idea is to use bindkey to bind PgUp and PgDown to appropriate commands. However, I can find only up-line-or-history and down-line-or-history in the docs, but not their page analogues. What am I missing?

1 Answer 1

4

Menu completion invokes the menu selection code form the zsh/complist module. This module only allows a limited selection of commands, but this does include “moves the mark one screenful up/down”. Oddly, you have to bind the key to forward-word/backward-word or one of their variants — presumably because the menu selection code reuses standard widgets and there's no standard widget for page up/down, whereas menu selection doesn't have words as such.

You can use the terminfo module to look up the key sequences that PgUp and PgDn send, or hard-code the ones that your terminal sends.

zmodload zsh/complist
zmodload zsh/terminfo
bindkey -M menuselect $terminfo[kpp] backward-word
bindkey -M menuselect $terminfo[knp] forward-word
1
  • I had to add zmodload zsh/complist to the .zshrc file to load the module before invoking bindkey, and then it worked. I guess that the module gets autoloaded when the completion is invoked, but before the module is loaded the keymap menuselect is not defined. An additional thanks for the pointer to terminfo module.
    – Boris Bukh
    Apr 21, 2020 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .