Created
April 15, 2020 03:02
-
-
Save hashimotor/79829a01b2be5109af7a8c3c1f229278 to your computer and use it in GitHub Desktop.
Execute venv/bin/activate etc. when entering specific directory
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
exec-venv(){ | |
case "$PWD" in | |
*/some-dir-with-venv) | |
if [ -z "${VIRTUAL_ENV}" ]; then | |
. ./venv/bin/activate | |
## Some other commands here | |
fi | |
;; | |
*/some-dir-with-venv/*) | |
## won't do anything | |
;; | |
*) | |
## when exit from repository directories | |
if [ "${VIRTUAL_ENV}" ]; then | |
deactivate | |
## Some other commands here | |
fi | |
;; | |
esac | |
} | |
export PROMPT_COMMAND="exec-venv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment