1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-24 05:00:07 +00:00

Document some logic in prompt_virtualenv()

This commit is contained in:
Alex Jurkiewicz 2023-10-12 11:27:57 +08:00
parent 862440ae11
commit ffc1f175c2

View file

@ -4285,11 +4285,19 @@ prompt_virtualenv() {
if (( _POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION )) && _p9k_python_version; then
msg="${_p9k__ret//\%/%%} "
fi
local v=${VIRTUAL_ENV:t}
# Determine virtualenv name
# VIRTUAL_ENV* are set inside virtualenvs. VIRTUAL_ENV is the virtualenv's
# on-disk path, VIRTUAL_ENV_PROMPT is `(name_of_virtualenv) `.
local v
# Use custom name if it was set (python -m venv -p "foo" .venv)
if [[ $VIRTUAL_ENV_PROMPT == '('?*') ' && $VIRTUAL_ENV_PROMPT != "($v) " ]]; then
v=$VIRTUAL_ENV_PROMPT[2,-3]
# Use parent directory name if virtualenv name is generic (eg .venv)
elif [[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]]; then
v=${VIRTUAL_ENV:h:t}
# Otherwise use the virtualenv name as-is
else
v=${VIRTUAL_ENV:t}
fi
msg+="$_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER${v//\%/%%}$_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER"
case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in