Tuesday, 8 March 2016

Add a new environment variable to $PATH on Mac OS X

In this tutorial we'll explain how to add a new path variable in OS X.

The file we have to modify is /etc/paths, which contains a list of paths that are added to the $PATH variable.
All the executable files contained in the directories listed in this file can be launched on the shell using their name.

Suppose we have to add git executables to the path variables, and their directory is /usr/local/test/bin.

Follow these steps:
  1. Open the shell
  2. Type sudo nano /etc/paths
  3. Add at the end of the list /usr/local/test/bin and enter your password
  4. Press ctrl+X to exit, and Y to save changes
  5. Press enter
Problem solved!

Now, let's verify if everything went well.

Type in the shell (a new window is required!) echo $PATH

You should see something like this (focus on the last item, which should be the directory you just added):

/usr/local/bin:/usr/bin:/opt/X11/bin:/usr/local/test/bin





No comments:

Post a Comment