direnv is a great tool for loading environment variables on a per-project basis.
The one catch is that it loads
.envrc files by default and not
.env. I found their instructions on how to load an
.env a little unclear for a new developer like myself so below I'll show what to do.
- you've installed
- you're on a mac or linux machine (sorry, Windows)
First, create a config directory for
Then create a config file
Open the config, and add
[global] load_dotenv = true
Save, and restart your shell
Now, when you go to a project with a
.env file, you can simply run
It will load the
.env instead of just looking for
I hope this helps someone else!