A simple direnv extension to automatically load environment variables from .env files using
dotenvx.
brew install chenasraf/tap/direnv-dotenvx
# or
brew tap chenasraf/tap
brew install direnv-dotenvx- 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.
In your .envrc:
use_dotenvx # loads .env or .env.default
use_dotenvx dev # loads .env.devThen run:
direnv allowdirenv-dotenvx respects the log_filter setting from your direnv config
(~/.config/direnv/direnv.toml). Only log messages matching the regex are shown.
For example, to disable all logs:
[global]
log_filter="^$"If no log_filter is set, all messages are shown by default.
⚠️ direnvapplies only explicitly exported variables from the.envrcenvironment.dotenvxhandles.envfiles without needingexportstatements, so your.envor.env.*files should use the standardKEY=valueformat. Always review your environment files before allowingdirenvto apply them, as they affect your local shell environment.
MIT
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.