direnv

https://direnv.net/:

sudo apt install direnv

fish

If you are using fish, add the following to ~/.config/fish/config.fish:

direnv hook fish | source

bash

From There is a hook for bash. The instructions are here…

Add the following line at the end of the ~/.bashrc file:

eval "$(direnv hook bash)"

Tip

Make sure it appears even after rvm, git-prompt and other shell extensions that manipulate the prompt.

Usage

Create a new terminal.

Create a .envrc file in your development folder (where you have the .env file) and add the following:

dotenv_if_exists
dotenv_if_exists .private

When you cd into a folder containing a .envrc file, you will get a warning:

.envrc is blocked. Run `direnv allow` to approve its content

# if you trust the file, run...
direnv allow

From uv: Making Local Python Workflows FAST and BORING in 2025