Created
August 20, 2012 09:07
-
-
Save dahlia/3402507 to your computer and use it in GitHub Desktop.
[virtualenvwrapper] automatic workon hook on cd
This file contains 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
export PROJECTS_HOME="$HOME/Projects" | |
function has_virtualenv__() { | |
if [[ "$VIRTUAL_ENV" == "" ]]; then | |
if [[ $(dirname "`pwd`") == $PROJECTS_HOME ]]; then | |
venvname=$(basename "`pwd`") | |
if [[ -d "$WORKON_HOME/$venvname" ]]; then | |
workon "$venvname" | |
fi | |
fi | |
fi | |
} | |
function venv_cd() { | |
builtin cd "$@" && has_virtualenv__ | |
} | |
alias cd=venv_cd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment