Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to make completion menu select navigation not wrap around?

Marlon Richert wrote on Sat, 04 Apr 2020 18:06 +0300:
> When using arrow keys to navigate the completion menu, I do not want it to
> wrap around (to the bottom row) when I press the up arrow key when I’m on
> the top row of the menu. Instead, I want to go back to the command line.
> Is there a zstyle to turn off menu wrapping? Or inside a widget function,
> is there a parameter or function I can query to tell if the menu is open
> and which line we’re on (so that I can then `send-break` instead of doing
> `up-line`)?

Sorry for the late answer.  The «menuselect» map can be used to bind
keys for navigating the menu, for example, to use Vi-like hjkl

bindkey -M menuselect "h" backward-char
bindkey -M menuselect "j" down-line-or-history
bindkey -M menuselect "k" up-line-or-history
bindkey -M menuselect "l" forward-char

So I suppose you could bind up/down to functions that
decrement/increment a global counter respectively, and have the "up"
function send-break when the counter reaches zero.  Won't be perfect,
since pressing <Right> repeatedly can move to the next line, but might
work "well enough" in practice.



Messages sorted by: Reverse Date, Date, Thread, Author