improve appearance of venv info

This commit is contained in:
philip82148 2023-10-24 12:24:04 +09:00
parent 83755bd27b
commit d5694fe648

View file

@ -210,7 +210,14 @@ _simplerich_prompt() {
if [ -v CONDA_DEFAULT_ENV ]; then if [ -v CONDA_DEFAULT_ENV ]; then
echo "%{$fg[magenta]%}(${CONDA_DEFAULT_ENV})%{$reset_color%}" echo "%{$fg[magenta]%}(${CONDA_DEFAULT_ENV})%{$reset_color%}"
elif [ -v VIRTUAL_ENV ]; then 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 fi
} }