Tutorial for adding to PATH variable in OS X (sublime text example)

There are a lot of resources online for showing how to add to your PATH variable. Unfortunately, many don't seem to walk you through the process. Here's an example of how to add ~/bin (which really means /Users/yourusername/bin) to your PATH. In this example, I also address what to do if you have issues with getting sublime text (nice editor--get it here) to run from the command line.

You can add something to your $PATH variable for your current session with the export PATH=... command, but if you want it to persist for the next time you open a terminal application, the easiest way is to just go edit /etc/paths. You'll need admin access to do so. You can do this:

sudo pico /etc/paths

After putting in your password, you'll see a document that has all of the directories currently in your path, one per line. Add a line with /Users/*you*/bin, replacing 'you' with your user name, exit (ctrl+x) and save changes (y). Now when you exit terminal and re-open, you should be able to type

subl --help

without an error. If you're still getting an error, go to your ~/bin directory. See if you can run the binary directly from there:

cd ~/bin
./subl --help

If that doesn't work, the simlink might have been created as a directory with the binary under it rather than just the binary. Try removing it and re-creating:

rm subl
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl