direnv
command-line·tool·productivitydirenv loads and unloads environment variables depending on which directory you are in. You put a .envrc file in a project folder, and whenever you cd into it direnv loads whatever is in that file into your shell. When you leave the folder, it unloads them again.
Install it (on Arch, sudo pacman -S direnv), then add the shell hook so it runs on every prompt:
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
Now put the variables a project needs in a .envrc:
export DATABASE_URL="postgres://localhost/myapp"
export PATH="$PWD/bin:$PATH"
The first time, direnv asks you to approve the file with direnv allow, so a repo can’t run code in your shell without you saying so. After that the variables appear when you enter the folder and disappear when you leave.
I use it to keep per-project settings and secrets out of my global shell config. If you also want per-project language versions, mise does the same trick for toolchains.