Last active
May 19, 2016 12:32
-
-
Save Endika/f0f2d85a67a85194f9cdf3160d71e1bf to your computer and use it in GitHub Desktop.
Auto workon, if enviroment detects
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
#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