unclutter your .profile
open sourceMITself-hostablefree
direnv is a shell extension that loads and unloads environment variables depending on the current directory. Before each prompt it looks for an authorized .envrc (optionally .env) in the current and parent directories, evaluates it in a bash subshell and exports the result into your shell. It is a single static binary with hooks for bash, zsh, fish, tcsh, elvish, PowerShell, murex and nushell.
Ways to install
Package managers
Problems it solves
- load a project's environment variables automatically when I cd into it
- my .zshrc is full of exports for different projects
- unset API keys when I leave a project directory
- activate the right virtualenv automatically per folder
- different AWS profiles for different repos without remembering to switch
- per-directory PATH additions like node_modules/.bin
- load a .env file into my shell, not just into the app
- hook nix shell or other dev environments into my normal shell
- I keep forgetting to source the project env file before running commands
- different AWS credentials per project directory
- set environment variables only while I am inside a project folder
- my .bashrc is full of project-specific exports
- automatically activate the right virtualenv when I cd into a repo
- load 12-factor app config from a file in development
- unset project env vars automatically when I leave the folder
- per-directory PATH additions for project scripts
Features
- .envrc per directory
- authorization of env files
- optional .env loading
- stdlib helpers
- many shells supported
- .envrc loading/unloading
- explicit allow for security
- optional .env support
- many shell hooks
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what direnv does.
