Directory local variables with direnv
So I recently got notified about direnv
which is a tool that allow you to set
up directory local environmental variables. This is really handy for project
directories which might need to point out local configurations and external
tools.
It can be installed with
sudo dnf install direnv
And oh-my-zsh has a plugin for it, which can be enabled with
plugins=(direnv)
Once you have it set up you can create a file called .envrc
, where you set up
your variables:
echo 'export FOO=BAR' >> .envrc
direnv allow
direnv allow
is used to indicate that you intend to use the values set up in
.envrc
. This permission actually need to be updated every time .envrc
is
modified.
More information about direnv
can be found on the direnv website.