I use the official Git Bash prompt support for displaying the current branch as part of the prompt.
My problem is that activating a Python virtual environment (python -m venv <dir>) using source bin/activate doesn't display the virtual environment name - (atlassian-watchdog) - as part of the Bash prompt:
nlykkei:~/projects/atlassian-watchdog (master *)$
I've a strong feeling that it's failing, because I use PROMPT_COMMAND in ~/.bashrc instead of PS1, but GIT_PS1_SHOWCOLORHINTS works only with PROMPT_COMMAND.
Is there any way to use PROMPT_COMMAND with Python virtual environments, so that the environment name gets added to the prompt, when it's active?
~/.git-prompt.sh:
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.
bin/activate:
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
if [ "x(atlassian-watchdog) " != x ] ; then
PS1="(atlassian-watchdog) ${PS1:-}"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
~/.bashrc:
# git prompt
source ~/.git-prompt.sh
GIT_PS1_SHOWCOLORHINTS=1
PROMPT_COMMAND='__git_ps1 "\u:\w" "\\\$ "'