Directory specific environment variables with direnv
direnv is a very simple but useful tool. Create a .envrc
file that defines some environment variables, e.g.:
When you cd
into that directory, the environment variables are loaded. When you cd
out, they are unloaded.
Installation on Ubuntu §
On Ubuntu it’s as simple as sudo apt-get install direnv
. Then add the following to your ~/.bashrc
and restart your shell:
Other distributions and shells §
It’s packaged on most distributions and supports all major shells.