The state every program reads
Environment variables are key/value pairs every running process can read. $HOME, $PATH, $USER, $LANG — all of them shape how programs behave. printenv prints them all; echo $VAR shows one.
Set, export, unset
VAR=value— local to this shell only.export VAR=value— passed to every child process.unset VAR— remove it.VAR=value cmd— set just for one invocation.HTTPS_PROXY=... curl ...is the canonical example.
Why export matters
Without export, the value lives only in the current shell. If you spawn python script.py and the script reads os.environ['VAR'], it sees nothing. Always export for tools to pick it up.
The variables you'll touch
$PATH— executable lookup.$HOME— your home dir.$EDITOR— whatgit commitopens (set tonvim,code -w,cursor -w).$PAGER— whatmanuses (set toless -R).$LANG/$LC_*— locale and character set.$TERM— terminal type.
Where to set them
Interactive use → ~/.zshrc. Login-time only → ~/.zprofile. The full breakdown is the next lesson; for now remember that one of those files is the right place.
An environment variable is copied to children
An exported value reaches processes created afterward; it does not flow backward into an existing parent or sideways into a sibling. Use that direction to explain why a new terminal and a long-running application see different values.
Separate secret delivery from secret storage
Environment values can leak through child processes, diagnostics, or crash reports. Keep tokens out of plaintext startup files and inject them from a credential store at the narrowest runtime boundary. A convenient transport is not a safe store.