Last active
May 19, 2022 10:45
-
-
Save anuragregmi/0ff61fba29a0b4a09a92a715e2f3bc00 to your computer and use it in GitHub Desktop.
Override builtin cd to enable virtualenv on cd command
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
# include this in your .bashrc or .zshrc | |
function activateVenv() { | |
# if virtual env exits then source | |
if [ -d "./venv" ] | |
then | |
source ./venv/bin/activate | |
fi | |
} | |
function cd() { | |
builtin cd "$@" | |
activateVenv | |
} | |
# check for virtualenv on startup as well | |
activateVenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment