Skip to content

Instantly share code, notes, and snippets.

@TimonLukas
Created September 29, 2019 00:16
Show Gist options
  • Save TimonLukas/a4c5d45aef4ef50b4e2b5e175d96af92 to your computer and use it in GitHub Desktop.
Save TimonLukas/a4c5d45aef4ef50b4e2b5e175d96af92 to your computer and use it in GitHub Desktop.
Auto-activate venv
function cd() {
builtin cd "$@"
if [[ -z "$VIRTUAL_ENV" ]] ; then
if [[ -d ./venv ]] ; then
source ./venv/bin/activate
fi
else
parentdir="$(dirname "$VIRTUAL_ENV")"
if [[ "$PWD" =~ $parentdir ]] ; then
else
deactivate
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment