Skip to content

Instantly share code, notes, and snippets.

@ryanhs
Created May 19, 2017 04:03
Show Gist options
  • Select an option

  • Save ryanhs/faf1dd5163fb972339e500870d40f6f6 to your computer and use it in GitHub Desktop.

Select an option

Save ryanhs/faf1dd5163fb972339e500870d40f6f6 to your computer and use it in GitHub Desktop.
execute something when entering directory added on .bashrc
# virtualenv auto activation
function cd {
builtin cd "$@"
DEACTIVATE_TYPE="function";
DEACTIVATE_EXIST=$(type -t deactivate);
if [ -d ".venv" ]
then
source .venv/bin/activate #auto activate
else
if [ "$DEACTIVATE_EXIST" == "$DEACTIVATE_TYPE" ]; then deactivate; fi #auto deactivate
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment