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" ;;