Back

Environment variables

Environment variables are named values your shell and programs can read, like PATH or HOME. You can set your own for a single session or save them in your shell config so they're always there.

echo $HOME            # print a variable
echo $PATH
env                   # list all

export API_KEY=abc123 # set for this session
echo $API_KEY

# Make it permanent (zsh)
echo 'export API_KEY=abc123' >> ~/.zshrc
source ~/.zshrc

# Set just for one command
PORT=4000 npm run dev

Roadmap