Last active
September 5, 2017 13:31
-
-
Save lee-pai-long/e4b0194eaad0d7e1c33d6a777083245a to your computer and use it in GitHub Desktop.
Force virtualenv prompt change with pyenv-virtualenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force prompt update with pyenv-virtualenv | |
# see: https://github.com/pyenv/pyenv-virtualenv/issues/135 | |
function virtualenv_prompt { | |
WANTED_PROMPT="(${VIRTUAL_ENV##*/}) $ORIGINAL_PROMPT" | |
# Current virtualenv | |
if [[ $VIRTUAL_ENV != "" ]] && [[ $PS1 != $WANTED_PROMPT ]]; then | |
PROMPT=$WANTED_PROMPT | |
else | |
PROMPT=$ORIGINAL_PROMPT | |
fi | |
PS1="$PROMPT" | |
} | |
export -f virtualenv_prompt | |
# Bash shell executes this function just before displaying the PS1 variable | |
export PROMPT_COMMAND='virtualenv_prompt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment