Skip to content

Instantly share code, notes, and snippets.

@lsemel
Created October 18, 2012 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsemel/3912866 to your computer and use it in GitHub Desktop.
Save lsemel/3912866 to your computer and use it in GitHub Desktop.
Add to .bash_profile to automatically activate a virtualenv matching the directory you cd into
function cd {
builtin cd "$@"
dirname=${PWD##*/}
if [ $dirname ] ; then
venv="/var/www/virtualenvs/"${dirname}
if [ -d $venv ] ; then
source ${venv}/bin/activate
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment