Last active
December 13, 2015 21:18
-
-
Save darklow/4976031 to your computer and use it in GitHub Desktop.
Auto-detect virtualenv relatively from current directory
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
# auto source virtual envs if it can find one | |
has_virtualenv() { | |
path="../env/bin/activate" | |
if [ -e $path ]; then | |
path=$(readlink -f $path) | |
if [ -z "$CURRENT_VENV_PATH" -o -z "$_OLD_VIRTUAL_PATH" -o "$CURRENT_VENV_PATH" != "$path" ] ; then | |
source $path | |
export CURRENT_VENV_PATH="$path" | |
echo -e "\e[01;30mvirtualenv $path activated\e[00m" | |
fi | |
fi | |
} | |
venv_cd () { | |
cd "$@" && has_virtualenv | |
} | |
alias cd="venv_cd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment