diff --git a/private_dot_zshrc b/private_dot_zshrc index 48a4321..7aed51a 100644 --- a/private_dot_zshrc +++ b/private_dot_zshrc @@ -120,7 +120,20 @@ plugins=(git zsh-autosuggestions sudo web-search dirhistory history) # every platform AND separately sourced from /opt/homebrew on macOS, so it # loaded twice on mac. The existence guard also stops the array referencing a # plugin that was never installed. -[[ -z $ZSH_AI_DISABLE && -d $ZSH_CUSTOM/plugins/zsh-ai ]] && plugins+=(zsh-ai) +# +# It also loads only when its provider has a key. The key comes from +# secrets.zsh, which a public-only machine does not have, and without it the +# plugin prints a " not set" warning on every interactive shell and does +# nothing else. ollama is local and needs no key. +case ${ZSH_AI_PROVIDER:-anthropic} in + gemini) _zai_key=GEMINI_API_KEY ;; + openai) _zai_key=OPENAI_API_KEY ;; + ollama) _zai_key= ;; + *) _zai_key=ANTHROPIC_API_KEY ;; +esac +[[ -z $ZSH_AI_DISABLE && -d $ZSH_CUSTOM/plugins/zsh-ai ]] && \ + [[ -z $_zai_key || -n ${(P)_zai_key} ]] && plugins+=(zsh-ai) +unset _zai_key # Guarded. Unguarded, a clean bootstrap produces a broken login shell and # nothing tells you why.