fix(cli): self-load compinit in the zsh completion file
Prepend a guard that runs `autoload -Uz compinit && compinit` when compdef isn't defined, so the generated zsh completion works without oh-my-zsh or if sourced before compinit.
This commit is contained in:
@@ -46,9 +46,12 @@ gen_completion() {
|
||||
local out="$1" shell="$2"
|
||||
case "$shell" in
|
||||
zsh)
|
||||
# Self-load compinit if compdef isn't defined yet (so the file works even
|
||||
# without oh-my-zsh, or if sourced before compinit).
|
||||
printf '%s\n' 'if ! whence compdef >/dev/null 2>&1; then autoload -Uz compinit && compinit -u; fi' > "$out"
|
||||
_CI_COMPLETE=zsh_source "$PROD_PY" -m ci_orchestrator 2>/dev/null \
|
||||
| sed -e "s#_CI_COMPLETE=zsh_complete ci)#_CI_COMPLETE=zsh_complete ${PROD_PY} -m ci_orchestrator)#" \
|
||||
-e '/\$+commands\[ci\]/d' > "$out" ;;
|
||||
-e '/\$+commands\[ci\]/d' >> "$out" ;;
|
||||
bash)
|
||||
_CI_COMPLETE=bash_source "$PROD_PY" -m ci_orchestrator 2>/dev/null \
|
||||
| sed -e "s#_CI_COMPLETE=bash_complete \$1#_CI_COMPLETE=bash_complete ${PROD_PY} -m ci_orchestrator#" > "$out" ;;
|
||||
|
||||
Reference in New Issue
Block a user