zsh完了セクションヘッダーのスタイルを指定する方法は?

zsh完了セクションヘッダーのスタイルを指定する方法は?

私のスクリーンショットでは、セクションタイトル(「最近のブランチ」、「ローカルヘッド」など)は、完成した提案と視覚的に区別されません。

compinstallスタイルを変えることはできないようです。

たとえば、セクションのタイトルを太字で表示したり、fg / bgの色を反転したりする方法は?

ここに画像の説明を入力してください。

ベストアンサー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。これによりフォーマットが設定されます。みんなさまざまな完成(ファイル、ディレクトリ、フィルタ...)。さまざまなカテゴリにさまざまなスタイルを設定することもできます(に渡された最初のパラメータを参照_descriptiongrep -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...) は、すべての完成者が常に一貫して使用するわけではありません。

おすすめ記事