Skip to content

Instantly share code, notes, and snippets.

@Endika
Last active May 19, 2016 12:32
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 Endika/f0f2d85a67a85194f9cdf3160d71e1bf to your computer and use it in GitHub Desktop.
Save Endika/f0f2d85a67a85194f9cdf3160d71e1bf to your computer and use it in GitHub Desktop.
Auto workon, if enviroment detects
#Copy in your .bashrc
export WORKON_HOME=$HOME/.virtualenvs
cd_venv(){
builtin cd "$@"
if [ -e .venv ]; then
. .venv
else
SEARCHING_VENV=$(basename "$PWD")
DEST_VENV=$WORKON_HOME/$SEARCHING_VENV
if [ -e "$DEST_VENV" ]; then
workon "$SEARCHING_VENV"
fi
fi
}
alias cd="cd_venv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment