fix(agnoster): respect conda changeps1 and escape env name (#14042)

Co-authored-by: John Pocock <john_pocock@me.com>
This commit is contained in:
Robby Russell
2026-09-10 13:49:39 +02:00
committed by GitHub
co-authored by John Pocock
parent 9bb15d681a
commit e6561f578f
+5 -2
View File
@@ -314,8 +314,11 @@ prompt_dir() {
# Virtualenv: current working virtualenv
prompt_virtualenv() {
if [ -n "$CONDA_DEFAULT_ENV" ]; then
prompt_segment magenta $CURRENT_FG "🐍 $CONDA_DEFAULT_ENV"
# Skip the conda segment when conda is already showing the environment itself,
# i.e. when changeps1 is left on. This mirrors how VIRTUAL_ENV_DISABLE_PROMPT
# is handled below, and stops the name appearing twice in the prompt.
if [[ -n "$CONDA_DEFAULT_ENV" && -z "$CONDA_PROMPT_MODIFIER" ]]; then
prompt_segment magenta $CURRENT_FG "🐍 ${CONDA_DEFAULT_ENV:t:gs/%/%%}"
fi
if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})"