Load your environment in the terminal automatically
Have your terminal pick up an environment’s variables, the keys and settings your code reads such as DATABASE_URL, when you go into its folder, and drop them when you leave.
Before you start:
- An environment in keypaste holding your variables, under Environments in the sidebar.
- zsh, bash or fish on a Mac or Linux, or PowerShell on Windows.
Tell keypaste where the code lives
Section titled “Tell keypaste where the code lives”- In Environments, choose your environment.
- Under its name, click Choose folder… and pick your code’s folder. If a folder is already shown, Change… picks another folder or stage.
The folder uses the dev stage unless you choose another.
Add one line to your terminal
Section titled “Add one line to your terminal”- Open Settings › General. Under Shell hook, keypaste shows the line for your shell.
- If it says a terminal can’t run keypaste yet, link the keypaste command first, as it offers.
- Copy the line, paste it at the end of the file keypaste names, such as
~/.zshrc, and save the file. keypaste never edits it for you. - Open a new terminal window.
Use it
Section titled “Use it”- Keep keypaste open with your vault unlocked.
- In the terminal, go into the folder, such as
cd ~/code/shop. - The first time in each terminal window, keypaste asks, naming the environment, the stage, the variables and the folder. Click Allow in this terminal.
Everything you start in that terminal now gets the variables, and leaving the folder removes them. The terminal loads them again without asking each time it comes back, until keypaste locks or quits, which removes them too.
To use another stage in this terminal, type keypaste stage staging.
If it doesn’t work
Section titled “If it doesn’t work”- Nothing loads. Check that keypaste is unlocked and that you opened a new terminal after adding the line.
- You clicked Deny. That terminal doesn’t ask again until it leaves the folder. Go out and back in.
proddoesn’t load. A protected stage never loads on its own. Run one command with it instead:keypaste run -p prod -- npm start.- An AI tool started there doesn’t get the variables. That’s on purpose: keypaste holds them back from
claude,codex,cursor-agentandaiderstarted in that terminal.
Related
Section titled “Related”- Use your vault’s env in a project
- Connect an AI tool
- Full details: every shell, what never loads, and the limits