Skip to content

Commit b039ea0

Browse files
author
Rakotomandimby Mihamina
authored
Merge pull request #551 from Mohjive/patch-1
Use prompt from venv, if set
2 parents 17ef3a6 + 66780b9 commit b039ea0

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
@@ -653,7 +653,13 @@ function gp_add_virtualenv_to_prompt {
653653
local ACCUMULATED_VENV_PROMPT=""
654654
local VENV=""
655655
if [[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT+x}" ]]; then
656-
VENV=$(basename "${VIRTUAL_ENV}")
656+
if [[ -n "${VIRTUAL_ENV_PROMPT-}" ]]; then
657+
# first trim any starting white space and parenthesis, and then do the same to the end
658+
VENV="${VIRTUAL_ENV_PROMPT#"${VIRTUAL_ENV_PROMPT%%[![:space:]]*}("}"
659+
VENV="${VENV%")${VENV##*[![:space:]]}"}"
660+
else
661+
VENV=$(basename "${VIRTUAL_ENV}")
662+
fi
657663
ACCUMULATED_VENV_PROMPT="${ACCUMULATED_VENV_PROMPT}${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
658664
fi
659665
if [[ -n "${NODE_VIRTUAL_ENV-}" && -z "${NODE_VIRTUAL_ENV_DISABLE_PROMPT+x}" ]]; then

0 commit comments

Comments
 (0)