Skip to content

Instantly share code, notes, and snippets.

@orue
Last active March 7, 2020 18:22
Show Gist options
  • Save orue/951ea028074ff89cff31894ea092a85d to your computer and use it in GitHub Desktop.
Save orue/951ea028074ff89cff31894ea092a85d to your computer and use it in GitHub Desktop.
Auto Activate/Deactivate Python Virtual Enviroment
# 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