答案1
看info zsh format
(您可能需要安装一个zsh-doc
包或等效项)。
您可以设置format
zstyle
完成:
zstyle ':completion:*' format '%K{blue}%F{yellow}Completing %d:%k%f'
会将完成标题显示为Completing recent branches:
蓝色背景上的黄色。
您可以在以下菜单中找到它compinstall
:
3. Styles for changing the way completions are displayed and inserted.
[...]
1. Change appearance of completion lists: allows descriptions of
completions to appear and sorting of different types of completions.
[...]
1. Print a message above completion lists describing what is being
completed.
[...]
You can set a string which is displayed on a line above the list of matches
for completions. A `%d' in this string will be replaced by a brief
description of the type of completion. For example, if you set the
string to `Completing %d', and type ^D to show a list of files, the line
`Completing files' will appear above that list. Enter an empty line to
turn this feature off. If you enter something which doesn't include `%d',
then `%d' will be appended. Quotation will be added automatically.
description>
你会发现确实compinstall
将样式设置为zstyle ':completion:*' format
.这设置了格式全部各种补全(文件、目录、过滤器……)。您还可以为不同的类别设置不同的样式(请参阅传递给 的第一个参数_description
)grep -rw _descriptions $fpath
:
zstyle ':completion:*:*director*' format '%F{blue}%BCompleting %d:%b%f'
zstyle ':completion:*:*file*' format '%F{magenta}%BCompleting %d:%b%f'
# fallback:
zstyle ':completion:*:descriptions' format '%BCompleting %d:%b'
虽然你会发现那些标签( files
, directories
...) 并不总是被所有完成者一致使用。
答案2
我找到了一个解决方案https://github.com/solnic/dotfiles/blob/master/home/zsh/completion.zsh。
相关摘录是
// needs 'autoload -U colors && colors'
zstyle ':completion:*:descriptions' format "%{${fg_bold[magenta]}%}= %d =%{$reset_color%}"