Zsh color partial tab completions

左心房为你撑大大i 提交于 2019-12-04 17:23:29

问题


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:

Full size image: http://i.imgur.com/tN6w3.png


回答1:


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




回答2:


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

[1]. ZSH highlight on tab




回答3:


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.



来源:https://stackoverflow.com/questions/8300687/zsh-color-partial-tab-completions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!