direnv
Shell extension that automatically loads and unloads environment variables based on current directory
direnv is a shell extension that automatically manages environment variables based on your current directory. It monitors for .envrc files in the current and parent directories, loading their exported variables when you enter a directory and unloading them when you leave.
The tool works by checking for .envrc files before each shell prompt and executing them in a bash sub-shell to capture environment changes. It supports all major shells including bash, zsh, fish, tcsh, elvish, powershell, murex, and nushell. direnv requires explicit authorization of .envrc files through direnv allow as a security measure to prevent automatic execution of untrusted code.
direnv includes a standard library of utility functions accessible within .envrc files, such as PATH_add for path manipulation and dotenv for loading .env files. Users can extend functionality by creating custom functions in ~/.config/direnv/direnvrc. The tool is compiled as a single static executable for performance and supports creating isolated development environments, loading 12factor app configurations, and managing deployment secrets on a per-project basis.
Alternatives & related tools
shfmt
Shell script formatter built on a Go parser for POSIX sh, Bash, Zsh and mksh. The same repo ships a syntax package, shell helpers and an interpreter.
up
Interactive terminal UI for building Linux pipelines with live preview of command results
gum
CLI tool providing interactive components for shell scripts with input prompts, menus, spinners, and styling
tpm
Tmux Plugin Manager: installs, updates, and removes tmux plugins from GitHub or other git repositories, configured via ~/.tmux.conf.
Pure
ZSH prompt that shows git branch, dirty state, and async-checked unpushed/unpulled arrows, with exit-status coloring and command execution time.
add a badge to your README
Maintain direnv? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/direnv?utm_source=badge)<a href="https://www.trmn.sh/tools/direnv?utm_source=badge"><img src="https://www.trmn.sh/badge/direnv.svg" alt="Featured on trmn" height="20"></a>