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

Re: Limiting height of completion menu



On Sat, Dec 19, 2020 at 10:53 AM Vincent Bernat <bernat@xxxxxxxx> wrote:
>
> I was wondering if it would have been possible to limit the height of
> the completion menu. I am using:
>
> zstyle ':completion:*' menu yes=long select

This seems to work:

autoload add-zsh-hook
autoload add-zle-hook-widget
half-lines() {
  LINES=$((LINES/2))
}
full-lines() {
  # Force terminal query
  LINES=0
}
comp-lines() {
  full-lines
  compprefuncs=( half-lines )
}
add-zsh-hook preexec full-lines
add-zle-hook-widget line-init comp-lines

However, there is an odd side-effect in that the command line is
temporarily garbled if you are NOT using menu-select and the "do you
wish to see all X possibilities" prompt is printed.  It fixes itself
as soon as you answer yes/no, but it's curious that it happens in the
first place.

Note it does not work to use comppostfuncs=( full-lines ) ... the
comppostfuncs are run before menu-selection determines the screen
size.




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