From 7dea74e2ec4ee27844b2c87d131c340805e11296 Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 9 Jun 2026 23:51:53 +0200 Subject: [PATCH] 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. --- scripts/install-ci-alias.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/install-ci-alias.sh b/scripts/install-ci-alias.sh index c0d7004..0e0b668 100755 --- a/scripts/install-ci-alias.sh +++ b/scripts/install-ci-alias.sh @@ -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" ;;