Unclutter your .profile by loading environment variables per directory
direnv is a shell extension that automatically loads and unloads environment variables based on your current directory. It works by checking for .envrc files in the current and parent directories, loading them into a bash sub-shell, and making the exported variables available to your current shell. This allows you to create per-project isolated development environments without cluttering your global shell profile.
The tool is particularly useful for 12-factor app development, managing project-specific environment variables, and loading deployment secrets. It supports all common shells including bash, zsh, fish, tcsh, elvish, powershell, and others. direnv includes a standard library of utility functions like PATH_add to make managing environment variables easier and more reliable.
Being compiled into a single static executable, direnv is fast enough to run on every shell prompt without noticeable performance impact. It's language-agnostic and can be used to build solutions similar to rbenv, pyenv, and phpenv. The tool includes security features that require explicit authorization before loading .envrc files, ensuring that untrusted code doesn't automatically execute in your shell.
# via Package manager
See installation documentation for distribution-specific packages