Skip to content

Instantly share code, notes, and snippets.

@lee-pai-long
Last active September 5, 2017 13:31
Show Gist options
  • Save lee-pai-long/e4b0194eaad0d7e1c33d6a777083245a to your computer and use it in GitHub Desktop.
Save lee-pai-long/e4b0194eaad0d7e1c33d6a777083245a to your computer and use it in GitHub Desktop.
Force virtualenv prompt change with pyenv-virtualenv
# 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