Skip to content

Instantly share code, notes, and snippets.

@un1t
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save un1t/0758ea0d82091d4af12a to your computer and use it in GitHub Desktop.
Save un1t/0758ea0d82091d4af12a to your computer and use it in GitHub Desktop.
#!/bin/bash
virtualenv_auto_activate() {
GITPATH=`git rev-parse --show-toplevel 2>/dev/null`
if [[ "$GITPATH" != "" ]]
then
if [[ "$VIRTUAL_ENV" == "" ]]
then
[ -f $GITPATH"/python/bin/activate" ] && source $GITPATH"/python/bin/activate"
else
[ ! -f $GITPATH"/python/bin/activate" ] && deactivate
fi
else
if [[ "$VIRTUAL_ENV" != "" ]]
then
deactivate
fi
fi
}
PROMPT_COMMAND="virtualenv_auto_activate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment