In this quick post, I'll cover how to setup environment variables for your Windows and Mac machines. For those Linux users out there, fortunately, it's pretty identical to setting them up using the Mac instructions below.
Setting up environment variables for Windows
Launch Environment Variables in Windows.
Click on the Windows icon start menu and start typing 'environment variables' in the search box.
You should see search result such as "Edit the system variables". Go ahead and select this.
You will be prompted with the "System Properties" dialog. Click on the "Environment Variables"
Create a new Environment Variable
In the Environment Variable dialog, click on New.
A new New User Variable dialog should appear.
Go ahead and enter your desired environment variable.
The example below is setting an environment variable called
MY_VARIABLE_IDwith a value of
Click Ok to save.
Testing environment variables in Windows
To verify that the environment variables have been loaded and working correctly, we can carry out a quick test.
Launch Windows Command Prompt.
If you have one open already, be sure to close it down. Otherwise, it doesn't know to load the environment variables.
Then, type the following to verify if the environment variable has been loaded correctly.
For Powershell users
If loaded correctly, it will print out the corresponding environment variable.
Setting up environment variables For Mac and Linux users
To setup environment variables for Mac or Linux, we need to find out if your shell is running on
Launch a terminal and type the command below to identify what shell you are running.
Editing your zshrc or bashrc file
Once you have identified the type of shell we shall update the corresponding
For those that are running
zsh, we need to update the
zshrc file. For those running on
bash we need to update the
In your favourite editor, edit the relevant
rc file like so.
Add your environment variable like so
Save and close the file.
Testing environment variables on Mac or Linux
Launch a new terminal. Again, if you have one open already, be sure to close and re-open it. Otherwise, the newly saved environment variable will not be loaded.
For the fancy people using cmder in Windows
For those of you that use cmder, there is an alternative way.
In the folder location of where cmder is installed, there will be a folder called
You want to edit the
In the file, you want to add your environment variable like so
Be sure to save the file.
Testing environment variables in Cmder
Open a new terminal in Cmder and type the following command.
This should print out the corresponding environment variable.