zsh completion

basic notes on zsh completion system

SEAN K.H. LIAO

zsh completion

basic notes on zsh completion system

completion

TAB all the way.

zsh

zsh manual

compinit

initialize the completion system

1compinit -d ${XDG_CACHE_HOME:-$HOME}/.zcompdump
compdef

using a shell function generate completions

 1compdef function_to_use commands to complete
 2
 3# when used as the first line of an autoloaded function found during compinit
 4#compdef ...
 5
 6# reuse completions created for command2 for command1
 7compdef command1=command2
 8# ex:
 9alias tf=terraform
10compdef tf=terraform

bash

use bash completion in zsh

bash manual

bashcompinit

call after compinit

1bashcompinit
complete

how to complete commands

1complete -o option -[CF] command
2
3# commonly used to not add extra space
4-o nospace
5
6complete -C command_output_used_as_completion command
7complete -F function_output_used_as_completion command