Change Order of PATH Entries in Mac OS X

Homebrew prefers that `/usr/local/bin` get seen first so that `brew installed` programs will get used before native programs. You can change this in `.bash_profile`. The easiest way to edit .bash_profile is to open it in a command line editor — the dot before the file name means that it is normally hidden from view. You can “see” it if you enter `ls -a` at the command line, or, if you do some freaky things with the Finder. (I figure that when I’m in the Finder, I’m in one mode and shouldn’t play with things like hidden files. When I’m at the command line, then I’m in maker mode and nothing is invisible!) I use `vi` (because `emacs` scares me):

% vi .bash_profile

Depending upon anything you’ve done before or what’s been done before you, this file may or may not exist or it may or may not have anything in it. If it doesn’t exist, congratulations, you are in the process of creating it. If it does exist, you are now editing it.

My profile looks like this:

# Bash Profile

PS1=”[\W]% ”

# Homebrew
export PATH=/usr/local/bin:$PATH
export PATH=”$PATH:/usrs/local/Cellar”
export PATH=/usr/local/share/python:$PATH

# Blogpost
export PATH=”$PATH:/Users/john/local/blogpost”
export PATH=”$PATH:/Users/john/local/asciidoc”

# Emacs
alias emacs=’/usr/local/Cellar/emacs/23.3b/bin/emacs’

alias Learn=’cd Dropbox/personal/programming/learn’

Being a humanist type, I have to name my file, and that’s what you see on the first line. That’s followed by my preference for how I want my prompt to look. Next up is my adjustments to my PATH in order to take advantage of my brewed installations. Everything else should be equally self-explanatory.

You need to log out of your terminal session and then back in in order to enjoy the fruits of your PATH labors.

I did see a note from someone about how changing `/etc/path` might be better, but from some comments on StackOverflow, it seems like that might be a bad idea. A very bad idea.