Skip to content

Instantly share code, notes, and snippets.

@nicinabox
Last active Jan 26, 2018
Embed
What would you like to do?
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