Last active
January 26, 2018 16:59
-
-
Save nicinabox/65ba30cae9b05fcfcc90de4281b4e7b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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