Last active
March 7, 2020 18:22
-
-
Save orue/951ea028074ff89cff31894ea092a85d to your computer and use it in GitHub Desktop.
Auto Activate/Deactivate Python Virtual Enviroment
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
# Auto Activate/Deactivate Python Virtual Enviroment | |
function venv_activate() { | |
if [[ -d $PWD/venv ]]; then | |
echo 'Activating Python virtualenv' | |
source $PWD/venv/bin/activate | |
else | |
if [ "$VIRTUAL_ENV" ] && [ ! -d $PWD/venv ]; then | |
echo "Deactivating Python Virtualenv" | |
deactivate | |
fi | |
fi | |
} | |
chpwd_functions=(${chpwd_functions[@]} "venv_activate") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment