Created
April 13, 2012 00:41
-
-
Save toranb/2372372 to your computer and use it in GitHub Desktop.
Auto workon virtualenv bash script based on current directory name
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
workon_virtualenv() { | |
if [ -e .git ]; then | |
current_dir="${PWD##*/}" | |
if [ -e ~/virtualenvs/$current_dir ]; then | |
deactivate >/dev/null 2>&1 | |
source ~/virtualenvs/$current_dir/bin/activate | |
fi | |
fi | |
} | |
virtualenv_cd() { | |
cd "$@" && workon_virtualenv | |
} | |
alias cd="virtualenv_cd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment