Rootree
Github Logo

Environment Variables

Github Logo

Windows:

If you are using Windows, you can follow these steps to add environment variables:

Without PowerToys

  1. Open the Start menu and search for “Environment Variables” or “Edit the system environment variables.”
  2. Click on the “Environment Variables” button.
  3. In the “System Variables” section, click on the “New” button to create a new variable or select an existing variable and click on the “Edit” button to modify it.
  4. Enter the variable name and its value.
  5. Click “OK” to save the changes.

With PowerToys

  1. Open the PowerToys quick access and click on “Environment Variables.”
  2. Next to “User” click “Add Variable.” If you want to edit an existing variable, click on the “Edit” button next to the variable you want to edit.
  3. Enter the variable name and its value.
  4. Click “Save” to save the changes.

You can also refer to the Microsoft documentation for more details: Windows environment variables

macOS and Linux:

For macOS and Linux-based systems, you can typically add environment variables by modifying configuration files. Here’s a general approach:

  1. Edit the appropriate configuration file using a text editor like “nano,” “vim” or “TextEdit.”
    • The file you need to edit depends on your shell (e.g., Bash, Zsh, Fish). Common files include .bashrc, .bash_profile, .zshrc, .profile, or .bash_login.
    • The file will typically be located in your home directory (e.g., /Users/username/.zshrc).
    • .zshrc is typically the file you want to edit if you are using a Mac.
  2. Add a line in the file in the following format:
      export VARIABLE_NAME="variable_value"
    Replace VARIABLE_NAME with the name of the variable you want to set and variable_value with the desired value.
  3. Save the changes and exit the text editor.
  4. To apply the changes, either restart your terminal session or run the command
    source <filename>
    to reload the configuration file.

It’s important to note that different distributions may have slight variations in their configuration files. Therefore, it’s recommended to consult the documentation or community resources specific to your distribution.