Adding a Directory to $PATH in MacOSX


I don’t program in bash often enough to remember how to set shell-variables, so I always have to look up that :
is the line I need to add to my ~/.bashrc file, if I want to add /extra/path1:extra/path2 to my $PATH.

In fact, the reason for this post is because I had to look this up again tonight. The Title Case words in the title are the google query I used, but the results I found were too verbose for me. A year or two from now, when I have to look this up yet again, I’ll at least know where to look for a short answer (Update: actually it turned out to be almost exactly 6 months, not 1-2 years.)

Back when I first wrote this, I was running OS X 10.4, and I recommended modifying /etc/profile, because it was self-explanatory, and updated $PATH for all users. I no longer recommend this, because in OS X 10.5, $PATH is defined in /etc/profile as:
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`

and I just don’t understand path_helper enough to know what damage not using it to update $PATH for the whole system could cause.

Explore posts in the same categories: MacOSX, Tips, UNIX

One Comment on “Adding a Directory to $PATH in MacOSX”

  1. CowDir Says:

    Pretty awesome article. Thanks! – CowDir

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: