-
-
Save ajpen/901b801c4019d0d9a5bfa5edf9d14db8 to your computer and use it in GitHub Desktop.
virtualenv-auto-activate-auto-deactivate with support for existing custom PROMPT_COMMAND
This file contains hidden or 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
#!/bin/bash | |
_virtualenv_auto_activate() { | |
if [ -e ".env" ]; then | |
# Check to see if already activated to avoid redundant activating | |
if [ "$VIRTUAL_ENV" = "" ]; then | |
source .env/bin/activate | |
fi | |
else | |
if [ "$VIRTUAL_ENV" != "" ]; then | |
deactivate | |
fi | |
fi | |
} | |
export PROMPT_COMMAND="_virtualenv_auto_activate; $PROMPT_COMMAND" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment