Skip to content

Commit 66780b9

Browse files
authored
Use prompt from venv, if set
It's possible to specify the prompt to be used for a venv, and if that is set, prefer that over the basename of the venv directory.
1 parent 51080c2 commit 66780b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gitprompt.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,13 @@ function gp_add_virtualenv_to_prompt {
649649
local ACCUMULATED_VENV_PROMPT=""
650650
local VENV=""
651651
if [[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT+x}" ]]; then
652-
VENV=$(basename "${VIRTUAL_ENV}")
652+
if [[ -n "${VIRTUAL_ENV_PROMPT-}" ]]; then
653+
# first trim any starting white space and parenthesis, and then do the same to the end
654+
VENV="${VIRTUAL_ENV_PROMPT#"${VIRTUAL_ENV_PROMPT%%[![:space:]]*}("}"
655+
VENV="${VENV%")${VENV##*[![:space:]]}"}"
656+
else
657+
VENV=$(basename "${VIRTUAL_ENV}")
658+
fi
653659
ACCUMULATED_VENV_PROMPT="${ACCUMULATED_VENV_PROMPT}${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
654660
fi
655661
if [[ -n "${NODE_VIRTUAL_ENV-}" && -z "${NODE_VIRTUAL_ENV_DISABLE_PROMPT+x}" ]]; then

0 commit comments

Comments
 (0)