compinit
compinit is a built-in function of the Z shell (zsh) that initializes the shell’s programmable completion system. It activates, configures, and loads completion definitions and helpers so that zsh can offer context-aware suggestions for commands, options, arguments, and filenames. The completion framework relies on definitions loaded from various sources and registered completion functions that integrate with the shell’s input handling.
Usage in typical setups involves loading the function and invoking it during startup:
The autoload declaration makes the function available without loading it immediately, while compinit performs the actual
Cache and performance: To speed startup, compinit builds a compiled cache of completion data and stores it
Security and compatibility: compinit conducts checks for security and integrity, including detection of insecure directories in
See also: Z shell, programmable completion, compdef, _complete, fpath.