Mac OS X Tip: Setting PATH environment variables
I’m still getting to grips with this OS X malarkey, and my latest challenge was how to set the PATH environment variables.
I started out wanting to add some aliases for the mysql and mysqladmin commands as I’ve just decided to have a bit of a play with django. On linux I used to edit my .bashrc file to do this, but the version of bash on Mac OS X (10.5.2) doesn’t seem to support this. Hunting around I realised that I should just add the path to these commands to my PATH environment variable, but again: not quite so simple.
I want these commands to be available to everyone, so it turns out you have to edit a file called paths in /etc:
sudo vi /etc/paths
And that was it. Easy when you know how! Oh, and remember to run vi as root using the sudo command….










July 31st, 2008 05:34
Hey there Mark.
I just read this post, great info. But after digging a little I found out that you can use another method to do what you’re saying. You just have to create a file inside /etc/paths.d ; for instance if I’d like to append the mysql directory to the PATH I would do this:
1) Create the file /etc/paths.d/mysql like this:
sudo touch /etc/paths.d/mysql
2) Edit the file:
sudo vim /etc/paths.d/mysql
3) Put the path inside the file:
/usr/local/mysql/bin
I posted three steps so everyone knows what they’re doing, but you could do it all by just creating the file and filling it with the path needed in PATH.
I think this method works better because it is more ordered at the end and you would have a file for each path you want to create for every program that needs it.
Hope this helps.
Cheers. Felipe.