Last active
January 8, 2016 16:34
-
-
Save gorhack/d554e7065e061f5b7284 to your computer and use it in GitHub Desktop.
Enter/Exit virtual environment when workon/deactiavated
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
#!/bin/bash | |
# This hook is sourced after every virtualenv is activated. | |
PS1="$_OLD_VIRTUAL_PS1" | |
PROJECT_DIR="$HOME/Documents/Development/virtualenvs/$(basename $VIRTUAL_ENV)" | |
if [ -d $PROJECT_DIR ]; then | |
# If we aren't already within the project dir, cd into it | |
if [[ ! `pwd` == "$PROJECT_DIR*" ]]; then | |
export PRE_VENV_ACTIVATE_DIR=`pwd` | |
cd "$PROJECT_DIR" | |
fi | |
fi | |
unset PROJECT_DIR |
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
#!/bin/bash | |
# This hook is sourced after every virtualenv is deactivated. | |
if [ $PRE_VENV_ACTIVATE_DIR ]; then | |
cd $PRE_VENV_ACTIVATE_DIR | |
unset PRE_VENV_ACTIVATE_DIR | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment