Skip to content

Instantly share code, notes, and snippets.

@nicinabox
Last active January 26, 2018 16:59
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 nicinabox/65ba30cae9b05fcfcc90de4281b4e7b6 to your computer and use it in GitHub Desktop.
Save nicinabox/65ba30cae9b05fcfcc90de4281b4e7b6 to your computer and use it in GitHub Desktop.
function auto_workon() {
CURPWD=`pwd`
if [[ $CURPWD = "$ACTIVE_CURPWD"* ]] && [ -n "${ACTIVE_ENV+1}" ]; then
return
fi
if [[ -f .venv ]]; then
NEXT_ACTIVE_ENV=`cat .venv`
if [[ $ACTIVE_ENV != $NEXT_ACTIVE_ENV ]]; then
ACTIVE_ENV=$NEXT_ACTIVE_ENV
ACTIVE_CURPWD=$CURPWD
unset NEXT_ACTIVE_ENV
workon $ACTIVE_ENV
fi
else
if [ -n "${ACTIVE_ENV+1}" ]; then
unset ACTIVE_ENV
unset ACTIVE_CURPWD
deactivate
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment