Skip to content

Instantly share code, notes, and snippets.

@jslopez
Last active October 12, 2015 07:18
Show Gist options
  • Save jslopez/3990739 to your computer and use it in GitHub Desktop.
Save jslopez/3990739 to your computer and use it in GitHub Desktop.
cd + virtualenv activation
# cd + virtualenv activation + ls
function cd() {
# default cd
builtin cd $1;
# virtualenv activation
GIT_DIR=`git rev-parse --git-dir 2> /dev/null`
if [[ $? == 0 ]]
then
if [[ -f $GIT_DIR/../.env/bin/activate ]]
then
. $GIT_DIR/../.env/bin/activate
else
if [[ $VIRTUAL_ENV != "" ]]
then
deactivate
fi
fi
else
if [[ $VIRTUAL_ENV != "" ]]
then
deactivate
fi
fi
# optional ls
ls
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment