Change order of PATH entries on Mac OS X

I wanted to have /usr/local/bin to be listed before /usr/bin in my PATH environment variable.

One way to achieve this would be to add a ~/.profile file with a line like this:

export PATH=/usr/local/bin:$PATH

This would result in /usr/local/bin being listed twice. It wouldn’t hurt but it’s not pretty either.

If you look at /etc/profile, you will see that the initial value of PATH is set by path_helper(8).

The right way to change the order of default paths is to edit /etc/paths. It contains one path per line, in descending order. Mine looks like this: