A direnv plugin to load .env or .env.{env} files using dotenvx, with automatic variable detection and shell-safe exports.
direnv-dotenvx
A simple direnv extension to automatically load environment variables from .env
files using
dotenvx.
π¦ Installation
Homebrew
brew install chenasraf/tap/direnv-dotenvx
# or
brew tap chenasraf/tap
brew install direnv-dotenvx
Manual
- Clone the repo somewhere:
mkdir -p ~/.config/direnv/lib
git clone https://github.com/chenasraf/direnv-dotenvx ~/.config/direnv/lib/direnv-dotenvx
- Symlink or source the loader:
ln -s ~/.config/direnv/lib/direnv-dotenvx/use_dotenvx.sh ~/.config/direnv/lib/use_dotenvx.sh
β
This makes the function use_dotenvx
available in all .envrc
files.
βοΈ Usage
In your .envrc
:
use_dotenvx # loads .env or .env.default
use_dotenvx dev # loads .env.dev
Then run:
direnv allow
π Security Note
β οΈ
direnv
applies only explicitly exported variables from the.envrc
environment.dotenvx
handles.env
files without needingexport
statements, so your.env
or.env.*
files should use the standardKEY=value
format. Always review your environment files before allowingdirenv
to apply them, as they affect your local shell environment.
π License
MIT
Contributing
I am developing this package on my free time, so any support, whether code, issues, or just stars is very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate just a small amount to help sustain this project, I would be very very thankful!

I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature, donβt hesitate to open an appropriate issue and I will do my best to reply promptly.