Add to the PATH on Mac OS X

I’ve been using ADB on my Mac quite a bit lately, while working with my Android device. Most ADB install guides I’ve found simply tell you to launch a Terminal window in the ADB directory and then execute using ./adb. While that’s fine, it does seem like several extra steps, especially when using ADB hundreds of times in a day.

So I decided just to add the ADB directory to my Mac’s “PATH”, therefore I can execute ADB from any Terminal prompt, regardless of what directory I’m working in. It makes working with ADB much more seamless, and more enjoyable. There’s a very neat way to add to the PATH variable in Mac OS X Mountain Lion and newer, the /etc/paths file.

To see what’s in your /etc/paths file, enter the following command in a Terminal window:

echo $PATH

To add to the PATH variable, open up Terminal, and run the following command:

sudo nano /etc/paths

Screenshot 2013-11-18 13.24.14Enter your password when prompted.

This will open the /etc/paths file in the Nano text editor. The /etc/paths file contains a list (one per line) of paths that are added to the $PATH variable in the shell.

Using the arrow keys, move to the bottom of the file, and enter the path you wish to add.

Screenshot 2013-11-18 13.24.22

Hit Control+O to “WriteOut” the file. That means save the changes to the file. Just hit Enter when you see the “File Name to Write” prompt.

Screenshot 2013-11-18 13.24.30

 

Then Hit Control+X to Exit the Nano editor.

To verify your new PATH, use the same command as before:

echo $PATH

You should now see an entry similar to before, but with the new entry appended to the end.

Screenshot 2013-11-18 13.24.58

There you go! You’ve added to the PATH variable on your Mac!

Next post:

Previous post: