Skip to content

Instantly share code, notes, and snippets.

@DazWorrall
Created September 6, 2012 09:43
Show Gist options
  • Save DazWorrall/3653962 to your computer and use it in GitHub Desktop.
Save DazWorrall/3653962 to your computer and use it in GitHub Desktop.
Automatically switch to a directory with a matching name when entering a virtualenv
#!/bin/bash
# This hook is run after every virtualenv is activated.
venv=`basename "$VIRTUAL_ENV"`
if [ -d "$HOME/src/$venv" ]; then
cd "$HOME/src/$venv"
fi
@DazWorrall
Copy link
Author

Thats in ~/.virtualenvs/postactivate. I typically name my virtualenvs the same as the source repository, and typically check them out to the same place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment