Search code examples
shellcolorszshtab-completion

Zsh color partial tab completions


Is it possible to color the completed part of the partial completion results in Zsh?

Fish does this by default (in Gentoo at least) as shown in the image below:

enter image description here

Full size image: https://i.sstatic.net/KaL1g.png


Solution

  • Yes, you can do it with things like that:

    zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==02=01}:${(s.:.)LS_COLORS}")'

    Just change the 01 and 02 colors so it matches your taste, for example to match your screenshot:

    zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==34=34}:${(s.:.)LS_COLORS}")';

    (Taken from reddit thread, added here to help people searching for this, like I did.)