Zsh completion configuration: Difference between revisions

From wikinotes
(Created page with "= Loading Completions = <blockquote> <source lang="bash"> fpath=(~/.zsh/completion $fpath) # add completion dir to $fpath autoload -U compinit # init autocompletio...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Documentation =
<blockquote>
{| class="wikitable"
|-
| completion system configuration || https://man.archlinux.org/man/extra/zsh/zshall.1.en#COMPLETION_SYSTEM_CONFIGURATION
|-
| format string types || https://man.archlinux.org/man/extra/zsh/zshall.1.en#SIMPLE_PROMPT_ESCAPES
|-
|}
</blockquote><!-- Documentation -->
= Tutorials =
<blockquote>
{| class="wikitable"
|-
| completion formatting tut || https://thevaluable.dev/zsh-completion-guide-examples/
|-
|}
</blockquote><!-- Tutorials -->
= Loading Completions =
= Loading Completions =
<blockquote>
<blockquote>
Line 12: Line 32:
* <code>autoload -U ~/.zsh/completion/_yourcompleter:t</code>
* <code>autoload -U ~/.zsh/completion/_yourcompleter:t</code>
</blockquote><!-- Loading Completions -->
</blockquote><!-- Loading Completions -->
= Customizing Completion Display =
<blockquote>
<syntaxhighlight lang="zsh">
zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'
</syntaxhighlight>
colours
<syntaxhighlight lang="yaml">
%F{green}...%f: fg colour
%K{green}...%f: bg colour
%B...%b:        bold
%U...%u:        underline
</syntaxhighlight>
<syntaxhighlight lang="yaml">
%d: description
%f:
</syntaxhighlight>
</blockquote><!-- Customizing Completion Display -->

Latest revision as of 23:57, 28 December 2021

Documentation

completion system configuration https://man.archlinux.org/man/extra/zsh/zshall.1.en#COMPLETION_SYSTEM_CONFIGURATION
format string types https://man.archlinux.org/man/extra/zsh/zshall.1.en#SIMPLE_PROMPT_ESCAPES

Tutorials

completion formatting tut https://thevaluable.dev/zsh-completion-guide-examples/

Loading Completions

fpath=(~/.zsh/completion $fpath) # add completion dir to $fpath
autoload -U compinit             # init autocompletion
compinit

The cleanest way to reload your autocompletion script is:

  • open a new terminal
  • autoload -U ~/.zsh/completion/_yourcompleter:t

Customizing Completion Display

zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f'

colours

%F{green}...%f: fg colour
%K{green}...%f: bg colour
%B...%b:        bold
%U...%u:        underline
%d: description
%f: