Created
October 19, 2016 17:07
-
-
Save philroche/72952920176d4d1714e3d29148be607f to your computer and use it in GitHub Desktop.
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
# Add the following to your ~/.bashrc making sure to set $WORKON_HOME variable | |
function cd() { | |
builtin cd "$1" | |
absolute_path=$(readlink -m "$1") | |
base_path=$(basename "$absolute_path") | |
if [ -z "$VIRTUAL_ENV" ] | |
then | |
if [ -d "$WORKON_HOME/$base_path" ] | |
then | |
echo "Activating $base_path virtualenv" | |
# Control will enter here if $DIRECTORY exists. | |
source "$WORKON_HOME/$base_path/bin/activate" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment