Skip to content

Instantly share code, notes, and snippets.

@eseceve
Forked from jslopez/gist:3990739
Last active December 10, 2015 02:48
Show Gist options
  • Save eseceve/4370295 to your computer and use it in GitHub Desktop.
Save eseceve/4370295 to your computer and use it in GitHub Desktop.
override "cd" command. Now: - Check virtualenv for activate/deactivate. - Check git and show a status. - Show directory files (with "ls").
# cd + virtualenv activation + ls + git status
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
fi
else
if [[ $VIRTUAL_ENV != "" ]]
then
deactivate
fi
fi
# optional ls
ls
if [ -d .git ]; then
git status
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment