mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-03-27 21:37:05 +01:00
Modify the `virtualenv_prompt_info` function to use the prompt string specified when creating the virtual environment, instead of just the basename of the environment. If `VIRTUAL_ENV_PROMPT` is not set, fall back to just using the basename of `$VIRTUAL_ENV`.
17 lines
662 B
Bash
17 lines
662 B
Bash
function virtualenv_prompt_info(){
|
|
[[ -n ${VIRTUAL_ENV} ]] || return
|
|
# Some versions of virtualenv (e.g the version bundled with 'uv') wrap the
|
|
# prompt in parentheses with a trailing space.
|
|
local venv_prompt="${(*)VIRTUAL_ENV_PROMPT:/#%(#b)\((*)\) /${match[1]}}"
|
|
|
|
if [ -z ${venv_prompt} ]; then
|
|
# Older versions of virtualenv do not set VIRTUAL_ENV_PROMPT, so fall back
|
|
# to the basename of the virtualenv path.
|
|
venv_prompt="${VIRTUAL_ENV:t}"
|
|
fi
|
|
|
|
echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${venv_prompt:gs/%/%%}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
|
|
}
|
|
|
|
# disables prompt mangling in virtual_env/bin/activate
|
|
export VIRTUAL_ENV_DISABLE_PROMPT=1
|