Back to blog
Load environment variables automatically
Updated on 8/10/2025
Dir env
I have recently discovered , a tool that allows you to load environment variables automatically based on the current directory.
This is the TL;DR of how to set it up.
Installation
Add this to your ~/.zshrc:
Configure your project
In your project, create a .envrc file and make sure it's ignored by git. The
file needs to follow the right format:
You could use other .env formats but it will probably require other tools to
make their content available to direnv.
Give permissions
In your project's folder run:
Load the vars
In your project's folder run: