Set a variable temporarily
A variable set this way exists only in the current terminal session.
export MY_VAR="value"
Example with a database address:
export DatabaseURL="mysql://user:password@localhost:3306/mydatabase"

Do not put spaces around =.
Check it:
echo $DatabaseURL

Warning: Do not store real passwords in shell history or startup files that others can read. Keep secrets in a file with
chmod 600 or in a secrets manager.Set a variable permanently
Step 1: Open the .zshrc file
nano ~/.zshrc
(The file name is lower case, .zshrc.)
Step 2: Add the variable
export USER_NAME="Anna"

Save and exit.
Step 3: Apply the change
source ~/.zshrc

Step 4: Check it
echo $USER_NAME

Other Zsh startup files
~/.zshenvis read by every Zsh, even in scripts. Good forPATHand variables that all programs need.~/.zprofileis read by login shells.~/.zshrcis read by interactive shells./etc/zshenvsets variables for all users.
Useful commands
Show all variables:
printenv
Remove a variable:
unset USER_NAME
Add a folder to the PATH:
export PATH="$PATH:$HOME/bin"
Quick recap
export NAME="value"for the session.- Add the line to
~/.zshrcand runsource ~/.zshrcto keep it.