Setup
eval "$(direnv hook bash)"
Hook for bash (end of ~/.bashrc)
eval "$(direnv hook zsh)"
Hook for zsh (end of ~/.zshrc)
direnv hook fish | source
Hook for fish (config.fish)
direnv version
Print the installed version
direnv version <x.y.z>
Fail if older than this version
~/.config/direnv/direnv.toml
Global config file
direnv help
Show the help text
Trust
direnv allow [<path>]
Trust and load an .envrc
Needed again after every change to the file.
direnv deny [<path>]
Revoke trust for an .envrc
direnv edit [<path>]
Open in $EDITOR, allow on save
direnv prune
Drop stale entries from the allow list
direnv allow .env
Trust a .env file
Only loaded when load_dotenv is enabled.
[whitelist] prefix = ["<dir>"]
Auto-trust a directory tree
In direnv.toml. Dangerous: anyone able to write there can run
code as you.
Loading files
dotenv [<file>]
Load a .env file
dotenv_if_exists [<file>]
Load .env only if present
source_up
Inherit the nearest parent .envrc
Returns 1 if there is none; use source_up_if_exists to stay
silent.
source_env <path>
Load another .envrc
Not covered by the allow check.
source_env_if_exists <file>
Load another file if present
watch_file <file> ...
Reload when these files change
watch_dir <dir>
Reload when a directory changes
layout python3
Project virtualenv in .direnv/
layout python <exe>
Virtualenv from a given Python
layout pyenv <version>
Virtualenv from pyenv
layout uv
Sync and activate the uv project env
layout node
Add node_modules/.bin to PATH
layout go
Project GOPATH and bin on PATH
layout pixi
Load the pixi environment
use node [<version>]
Pick Node from .nvmrc or a version
use flake [<installable>]
Load a Nix flake devShell
use nix [-p <pkg>]
Load nix-shell environment
use rbenv
Put rbenv Ruby wrappers on PATH
use julia <version>
Load a Julia version