direnv
augments existing shells with a new feature that can load and unload environment variables depending on the current directory.
Created:
Activate python virtualenv automatically with direnv
I used the above trick to automatically load the correct virtualenv for the btbytes
directory that contains the source code of this website.
cat ~/btbytes/.envrc
$ if [ "$(uname)" = "Linux" ]; then
HOMEPATH=/home/pradeep
else
HOMEPATH=/Users/pradeep
fi
export VIRTUAL_ENV=$HOMEPATH/btbytes/.venv
export PATH=$HOMEPATH/btbytes/.venv/bin:$PATH