Skip to content

Instantly share code, notes, and snippets.

@nasrabadiAM
Last active January 27, 2018 07:03
Show Gist options
  • Save nasrabadiAM/9b4e523eeef517dabc43e8ed0afce91a to your computer and use it in GitHub Desktop.
Save nasrabadiAM/9b4e523eeef517dabc43e8ed0afce91a to your computer and use it in GitHub Desktop.

Set Global PATH variable in Mac OS X


With following steps we can add a variable directory to Mac Os X PATH permanently, so it will be there for always.

Instructions to add PATH Variable Globally


First, Lets find out your current PATH value.

To do that, Within the terminal, Fire this command:

echo $PATH

This should output the paths that are exist in your PATH now:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Now, Assume that we want add this path:

/Users/Android/sdk/platform-tools

To do this, We need to edit the .bash_profile and add it to the PATH variable.

Follow these simple steps:


  1. Within the Terminal, run vim ~/.bash_profile

  2. Type i and then paste the following at the top of the file:

     export PATH=/Users/Android/sdk/platform-tools:$PATH
    
  3. Hit ESC, Type :wq, and hit Enter

  4. In Terminal, run source ~/.bash_profile

  5. In Terminal, type in echo $PATH again and look for the updated string. If everything was successful, It should output the new path to your directory.

this is the updated PATH for me:

/Users/Android/sdk/platform-tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  1. In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment