Apple - How to launch TextMate (and probably other software) from the command line?

For Textmate there is a command line tool, mate, that can be installed. Once installed you just use mate <file> to open that file in text mate.

For application that don't have a command line tool, you can use the open command with the -a flag and the name of the application. i.e.

open -a iTunes

This also works for TextMate:

open -a "TextMate 2"

The executable file is located in the app's Contents/MacOS subfolder, so for TextMate 2, it would be:

/Applications/TextMate\ 2.app/Contents/MacOS/TextMate

But if you run it from the command line like that, it will hang the shell until the application is quit (on certain older OSs; this was resolved as of 10.8) If this happens to you, put an & at the end of the command to background the process. Such as:

/Applications/TextMate\ 2.app/Contents/MacOS/TextMate &

The problem with this is that if the shell exits (by quitting Terminal or closing the window) then TextMate is terminated without warning.