macOS
Setting Environment Variables in Shell
Temporary Environment Variables
These environment variables will only be available in the current shell session.Permanent Environment Variables
To make environment variables persist across sessions, add them to your shell configuration file (e.g.,.bashrc
, .bash_profile
, .zshrc
).
For Zsh:
Windows
Setting Environment Variables in PowerShell
Temporary Environment Variables
These environment variables will only be available in the current PowerShell session.Permanent Environment Variables
To make environment variables persist across sessions, add them to your PowerShell profile script (e.g.,Microsoft.PowerShell_profile.ps1
).
Setting Environment Variables in Windows Command Prompt
Temporary Environment Variables
These environment variables will only be available in the current Command Prompt session.Permanent Environment Variables
To make environment variables persist across sessions, you can use thesetx
command:
setx
, you need to restart the Command Prompt or any applications that need to read the new environment variable.
To display the environment variable in a new Command Prompt session: