From d5694fe64851ffb46c1c0cc37ebc8f3337938d81 Mon Sep 17 00:00:00 2001 From: philip82148 <92205270+philip82148@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:24:04 +0900 Subject: [PATCH] improve appearance of venv info --- simplerich.zsh-theme | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/simplerich.zsh-theme b/simplerich.zsh-theme index 7b2e44c..6c8dee7 100644 --- a/simplerich.zsh-theme +++ b/simplerich.zsh-theme @@ -210,7 +210,14 @@ _simplerich_prompt() { if [ -v CONDA_DEFAULT_ENV ]; then echo "%{$fg[magenta]%}(${CONDA_DEFAULT_ENV})%{$reset_color%}" elif [ -v VIRTUAL_ENV ]; then - echo "%{$fg[magenta]%}($(basename ${VIRTUAL_ENV}))%{$reset_color%}" + parent=$(dirname ${VIRTUAL_ENV}) + if [[ "${PWD/#$parent/}" != "$PWD" ]]; then + # PWD is under the parent + echo "%{$fg[magenta]%}($(basename ${VIRTUAL_ENV}))%{$reset_color%}" + else + # PWD is not under the parent + echo "%{$fg[magenta]%}(${VIRTUAL_ENV/#$HOME/~})%{$reset_color%}" + fi fi }