TRJ Live

Hello from Los Angeles

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!

1 Comment

  1. Better yet, don’t edit that file, but add a new one in “/etc/paths.d” (e.g. “/etc/paths.d/10-adb”).

    Or you could just symlink the “adb” (and/or “fastboot”) executable into a folder that’s already in your path:

    $ sudo mkdir -p /usr/local/bin
    $ sudo ln -s /path/to/adb /usr/local/bin/adb
    $ sudo ln -s /path/to/fastboot /usr/local/bin/fastboot

Leave a Reply

Your email address will not be published.

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2014 TRJ Live

Up ↑