Skip to content

Instantly share code, notes, and snippets.

@yigitbey
Created August 1, 2013 21:28
Show Gist options
  • Save yigitbey/6135503 to your computer and use it in GitHub Desktop.
Save yigitbey/6135503 to your computer and use it in GitHub Desktop.
export PREVPWD=`pwd`
export PREVENV_PATH=
handle_virtualenv(){
if [ "$PWD" != "$PREVPWD" ]; then
PREVPWD="$PWD";
if [ -n "$PREVENV_PATH" ]; then
if [ "`echo "$PWD" | grep -c $PREVENV_PATH`" = "0" ]; then
deactivate
PREVENV_PATH=
fi
fi
if [ -e "$PWD/bin/activate" ] && [ "$PWD" != "$PREVENV_PATH" ]; then
PREVENV_PATH="$PWD"
source $PWD/bin/activate
fi
fi
}
export PROMPT_COMMAND=handle_virtualenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment