ZSH autocomplete: Highlight prefix of suggestions which is already typed

I have configured ZSH to have bash-like autocomplete with

setopt noautomenu
setopt nomenucomplete

So on pressing tab, it only completes to the prefix that is unique among all suggestions and on pressing tab a second time, it shows a list of all possible completions with this prefix.
Is there a way to highlight the part in the suggestions that is already typed?

So for example if "do" is typed and tab is pressed two times to show the suggestions, it would show something like:

documents

downloads

docker

Asked By: niklassc

||

The closest thing that’s shipped with zsh is the show-ambiguity style. It highlights the first character that isn’t already typed.

zstyle ':completion:*' show-ambiguity true

The default highlighting is underline. You can replace true by 1 for bold, '1;31' for bold red, 1;41 for bold and a red background, etc.

In addition to not being exactly what you want, it has the major downside of suppressing the coloring of file names according to their type. Given how it is handled deep inside _main_complete, it looks really difficult to tune how it works without patching the zsh code.

Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.