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 $SHELL
in your Terminal. -
Depending on if you're using Bash or ZSH check if
~/.bashrc
or~/.zshrc
exists by runningopen ~/.bashrc
. Skip step 3 if it opens. -
Create the file with
touch ~/.bashrc
ortouch ~/.zshrc
if it doesn't already exist. Then open it withopen ~/.bashrc
oropen ~/.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 namedFOO
with the value ofbar
. -
Now just restart your terminal or reload the profile with
source ~/.bashrc
orsource ~/.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 $SHELL
in your Terminal. -
Depending on if you're using Bash or ZSH check if
~/.bashrc
or~/.zshrc
exists by runningxdg-open ~/.bashrc
orxdg-open ~/.zshrc
. Skip step 3 if it opens. -
Create the file with
touch ~/.bashrc
ortouch ~/.zshrc
if it doesn't already exist. Then open it withxdg-open ~/.bashrc
orxdg-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 namedFOO
with the value ofbar
. -
Now just restart your terminal or reload the profile with
source ~/.bashrc
orsource ~/.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
System
window click onAdvanced system settings
. -
In the new
System Properties
window click theAdvanced
tab 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 Variable
box 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
PATH
environment 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
PATH
environment variable.