Zinit Bootstrap and Initialization
Summary
Section titled “Summary”Zinit bootstraps by sourcing zinit.zsh from its install directory; this single source call sets up all commands, aliases, and the compdef intercept mechanism needed before any plugins are loaded.
Details
Section titled “Details”The canonical bootstrap snippet clones Zinit on first run and sources it on every run:
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"source "${ZINIT_HOME}/zinit.zsh"What sourcing zinit.zsh does:
- Defines the
zinitfunction and its aliases (zi,zini, etc., unlessZINIT[NO_ALIASES]=1). - Intercepts
compdefcalls so that plugins loaded beforecompinitcan still register completions (replayed later withzinit cdreplay). - Reads the
$ZINITassociative array for any path overrides set before the source call. - Does not load any plugins itself — that is left entirely to the user’s
.zshrc.
If zinit.zsh is sourced after compinit, you must manually register Zinit’s own completion:
autoload -Uz _zinit(( ${+_comps} )) && _comps[zinit]=_zinitAfter installation, run zinit self-update once to compile Zinit’s source files for faster subsequent loads.
Examples
Section titled “Examples”# Minimal bootstrap (auto-installs on first run)ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"source "${ZINIT_HOME}/zinit.zsh"
# Optional: register Zinit completion if sourced after compinitautoload -Uz _zinit(( ${+_comps} )) && _comps[zinit]=_zinit
# Compile Zinit after first installzinit self-updateCaveats / Common Mistakes
Section titled “Caveats / Common Mistakes”- The old variable-per-path style (
$ZPLG_HOME, etc.) has been removed; use the$ZINITassociative array instead. ZINIT[NO_ALIASES]=1must be set before sourcingzinit.zshto prevent alias creation.