Avoid Conda (base) in Zsh but Keep It in Bash (Oh My Zsh + Conda Prompt Fix)
How to prevent Conda from prepending (base) to your Zsh prompt while keeping it in Bash. This is useful when using a custom prompt like Oh My Zsh that already shows Conda/venv info, avoiding redundant display like (base) π base.
When using Oh My Zsh + Conda, you may see duplicated environment names in your prompt, like:
(base) π base user@host ~/projectThis happens because:
condaautomatically prepends(base)to your shell prompt.- Your Zsh theme (e.g.
agnoster) already includes the environment name viaprompt_virtualenv().
- Disable Condaβs
(base)prompt injection in Zsh - Keep it active in Bash
- Allow your Oh My Zsh theme to manage the prompt cleanly
Step 1: Add this to your ~/.zshrc:
# Prevent conda from modifying the prompt in zsh
export CONDA_CHANGEPS1=falseThis disables Condaβs prompt injection only for Zsh. Bash will still show (base) as usual.
Step 2 (Optional): Customize your themeβs prompt_virtualenv()
If you're using a theme like agnoster, you can edit ~/.oh-my-zsh/themes/agnoster.zsh-theme and adjust the function that displays environment names:
prompt_virtualenv() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
prompt_segment magenta $CURRENT_FG "π $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})"
fi
}This:
- Prefers
condaenv if bothVIRTUAL_ENVandCONDA_DEFAULT_ENVare set - Avoids
(env) [π env]duplication
-
Still seeing
(base)? Run:echo $PROMPT
If you see
(base)in the raw prompt string, itβs injected by Conda. -
Want to re-enable globally? Run:
conda config --set changeps1 True
zsh conda base prompt, oh-my-zsh conda duplicate prompt, disable conda base zsh, conda PS1, prompt_virtualenv, CONDA_CHANGEPS1, ohmyzsh conda, zsh bash conda environment, zsh remove (base), conda venv zsh prompt
Above content is generated by ChatGPT after LLM and I fix this problem together.