Autoload environment variables
When developing stateless microservices it can be tedious to set up the correct environment variables. You can teach your bash/zsh to load them on a per directory basis.
If you add this to your
.zshrc.local environment variables will
be set from a file called
.env if it is present in the directory you are
if [ -f $PWD/.env ]
export $(cat $PWD/.env | xargs)
builtin cd "$@"
In my project directory I have a
.env file with these contents:
Now everytime I run my project the correct environment is set.