name: zsh-completions
description: Add custom zsh completions for a tool.
argument-hint:
Add or update completions for the tool "$1".
Basics:
- Zsh loads completions from directories in
fpathviacompinit. - Oh My Zsh adds
$ZSH_CUSTOM/completionsand enabled plugin directories tofpathbeforecompinit.
Steps:
Find or generate the completion script.
If the tool supports it, generate a zsh completion file, for example:
$1 completion zsh > _${1}Choose a placement strategy.
Option A: custom completions directory (no plugin needed):
mkdir -p "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/completions" mv _${1} "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/completions/_${1}"Option B: custom plugin (useful if you want
plugins=(...)control):mkdir -p "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/${1}" mv _${1} "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/${1}/_${1}"Add
${1}to theplugins=(...)list in your.zshrcif you use Option B.Reload completions.
rm -f "$ZSH_COMPDUMP" exec zsh
Notes:
- Completion files must be named
_${tool}to be discovered. - If the tool has no generator, write
_toolmanually using zsh completion functions.