Zsh color partial tab completions

2019-03-25 06:07发布

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: http://i.imgur.com/tN6w3.png

3条回答
冷血范
2楼-- · 2019-03-25 06:26

I think [1] is thing you want. You need menu and select as @svlasov commented.

[1]. ZSH highlight on tab

查看更多
女痞
3楼-- · 2019-03-25 06:30

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.)

查看更多
倾城 Initia
4楼-- · 2019-03-25 06:38

I long time ago (2002) i wrote a experimental shell script to explain about control characters in shell. Check this out http://cltfc.sites.uol.com.br/ and you gonna see a lot of examples about how to color, make sounds and positioning of any char on your black screen. But this is for Bash and i do not know if they are compatible.

Anyway, for Zsh, check this page http://spiralofhope.wordpress.com/2009/04/23/zsh-ansi-prompt/ and you gonna see some examples of how to customize your prompt with colors. The same ANSI codes for colors and the same syntax should work when you use directly on the shell.

查看更多
登录 后发表回答