Skip to content

Instantly share code, notes, and snippets.

@anuragregmi
Last active May 19, 2022 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuragregmi/0ff61fba29a0b4a09a92a715e2f3bc00 to your computer and use it in GitHub Desktop.
Save anuragregmi/0ff61fba29a0b4a09a92a715e2f3bc00 to your computer and use it in GitHub Desktop.
Override builtin cd to enable virtualenv on cd command
# 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