Created
September 29, 2019 00:16
-
-
Save TimonLukas/a4c5d45aef4ef50b4e2b5e175d96af92 to your computer and use it in GitHub Desktop.
Auto-activate venv
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
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