Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.
They are part of the operating environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.
-
Find out if you're using Bash or ZSH by running the command
echo $SHELLin your Terminal. -
Depending on if you're using Bash or ZSH check if
~/.bashrcor~/.zshrcexists by runningopen ~/.bashrc. Skip step 3 if it opens. -
Create the file with
touch ~/.bashrcortouch ~/.zshrcif it doesn't already exist. Then open it withopen ~/.bashrcoropen ~/.zshrc. -
Add an environment variable using the following syntax
export FOO='bar'at the end of the opened file. This will add an environment variable namedFOOwith the value ofbar. -
Now just restart your terminal or reload the profile with
source ~/.bashrcorsource ~/.zshrc.
The tilde character ~ means your home folder and translates into /Users/yourusername.
-
Find out if you're using Bash or ZSH by running the command
echo $SHELLin your Terminal. -
Depending on if you're using Bash or ZSH check if
~/.bashrcor~/.zshrcexists by runningxdg-open ~/.bashrcorxdg-open ~/.zshrc. Skip step 3 if it opens. -
Create the file with
touch ~/.bashrcortouch ~/.zshrcif it doesn't already exist. Then open it withxdg-open ~/.bashrcorxdg-open ~/.zshrc. -
Add an environment variable using the following syntax
export FOO='bar'at the end of the opened file. This will add an environment variable namedFOOwith the value ofbar. -
Now just restart your terminal or reload the profile with
source ~/.bashrcorsource ~/.zshrc.
The tilde character ~ means your home folder and translates into /home/yourusername.
-
Open
cmd.exe -
Type
setx FOO bar. This will add an environment variable named FOO with the value of bar.
-
Right-click on the Computer icon on your desktop or start-menu and choose the Properties menu item.
-
In the new
Systemwindow click onAdvanced system settings. -
In the new
System Propertieswindow click theAdvancedtab and then theEnvironment Variables...button.
To avoid having to go through this arcane navigation, you can also create a desktop shortcut with target command of
rundll32.exe sysdm.cpl,EditEnvironmentVariables.
(Or just enter this command in the Windows Run box Win R.)
-
Click the first
New...button. -
In the
New User Variablebox you can add an environment variable name and value.
-
NVM# - For Windows 10 only, but supports the new environment variable extensions for Windows 10.
-
Path-Manager - Not limited to only setting
PATHenvironment variable, but any environment variable. Includes validation of path names. -
Rapid Environment Editor (RapidEE) - Comprehensive editor that includes display of read-only variables set by Windows.
-
Windows Environment Variables Editor - Nice, simple GUI layout reminiscent of Microsoft's GUI standards. Includes support for backing up and restoring environment variable "sets".
-
Windows Environment Variables Manager (EnvMan) - Nice separation of user and system environment variables and support for rearranging sequence of paths in
PATHenvironment variable.