Setting the PATH in OSX Leopard or above

Apple added a very handy .d (daemon?) directory in Leopard+ for appending to the global PATH variable. You can add to the path easily using the terminal:

sudo sh -c 'echo "[newpath]" >> /etc/paths.d/[pathname]'

For example to add the Android SDK to your path, you can enter the following command in the terminal:

sudo sh -c 'echo "/Developer/android-sdk-mac_x86" >> /etc/paths.d/AndroidPath'

OSX goes through each file in that directory, appending what it finds to the PATH. Makes installing / uninstalling utterly trivial.

All credit to dhaveconfig.

Leave a Reply