From 0207f6f8f46e768f7265e84a087df375c7655ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=98=A5=E6=97=AD?= Date: Thu, 14 Nov 2024 16:35:59 +0800 Subject: [PATCH 1/3] feat(theme): Make agnoster support conda environment --- themes/agnoster.zsh-theme | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 21c9cf7d5..ab1398b0b 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -314,6 +314,9 @@ prompt_dir() { # Virtualenv: current working virtualenv prompt_virtualenv() { + if [ -n "$CONDA_DEFAULT_ENV" ]; then + prompt_segment magenta $CURRENT_FG "🐍 $CONDA_DEFAULT_ENV" + fi if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})" fi @@ -354,9 +357,9 @@ prompt_aws() { build_prompt() { RETVAL=$? prompt_status - prompt_virtualenv prompt_aws prompt_context + prompt_virtualenv prompt_dir prompt_git prompt_bzr From 65c3e10e383aacc732522e45abc1792cf032e542 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sun, 8 Jun 2025 10:22:26 +0200 Subject: [PATCH 2/3] revert to original order --- themes/agnoster.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index ab1398b0b..c99b604b5 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -357,9 +357,9 @@ prompt_aws() { build_prompt() { RETVAL=$? prompt_status + prompt_virtualenv prompt_aws prompt_context - prompt_virtualenv prompt_dir prompt_git prompt_bzr From f4b09de2e782b98d8c856102302bec87404c32df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=98=A5=E6=97=AD?= Date: Tue, 10 Jun 2025 10:09:10 +0800 Subject: [PATCH 3/3] feat(theme): Optimize the display effect of conda in the agnoster theme; standardize the code --- themes/agnoster.zsh-theme | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 63452378d..b0106724b 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -80,6 +80,8 @@ esac # VirtualEnv colors : ${AGNOSTER_VENV_FG:=black} : ${AGNOSTER_VENV_BG:=blue} +: ${AGNOSTER_CONDA_FG:=${CURRENT_FG}} +: ${AGNOSTER_CONDA_BG:=magenta} # AWS Profile colors : ${AGNOSTER_AWS_PROD_FG:=yellow} @@ -314,9 +316,15 @@ prompt_dir() { # Virtualenv: current working virtualenv prompt_virtualenv() { - if [ -n "$CONDA_DEFAULT_ENV" ]; then - prompt_segment magenta $CURRENT_FG "🐍 $CONDA_DEFAULT_ENV" + if [[ -n $CONDA_DEFAULT_ENV && -z $CONDA_ENV_DISABLE_PROMPT ]]; then + # You can execute this command to disable conda native prompt. + # `conda config --set changeps1 False` + + local conda_prompt_prefix=${CONDA_PROMPT_PREFIX:-"🐍 "} + # local conda_prompt_prefix="$CONDA_PROMPT_PREFIX" + prompt_segment "$AGNOSTER_CONDA_BG" "$AGNOSTER_CONDA_FG" "$conda_prompt_prefix$CONDA_DEFAULT_ENV" fi + if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then prompt_segment "$AGNOSTER_VENV_BG" "$AGNOSTER_VENV_FG" "(${VIRTUAL_ENV:t:gs/%/%%})" fi