Coda and TextMate Tips for Mac OS X Terminal

Here are some tips for easy shell access to open files with TextMate and Coda from the terminal. I found and modified these while I’ve been dinking around with PhoneGap for iPhone (love it) and Android (jury is still out).  PhoneGap will likely be another post.

These tips allow you to easily open a file or files (or a whole directory in the case of TextMate awesomeness).  To open an html file in the current directory from the shell prompt becomes as easy as:

coda index.html
mate index.html

Opening all the HTML files (Coda) or all the editable files (TextMate) becomes:

coda .
mate .


1- Open Terminal
2- In terminal, enter: open .profile
3- Scroll to the bottom of the file and add the following lines of code

# TextMate
# set path and simple shell function
export TEXTMATE_PATH=/Applications/
mate () {
    $TEXTMATE_PATH $1 $2 $3 $4 $5 $6
# svn for TextMate (default editor, end-of-line types)
export LC_CTYPE=en_US.UTF-8

# Coda
# set path
export CODA_PATH=/Applications/
# function roughly like 'mate .' by expanding '.' to '*.htm*'
coda () {
if [[ "." == $1 ]]
    open -a $CODA_PATH *.htm*
    open -a $CODA_PATH $1 $2 $3

4- Save .profile
5- Quit Terminal
6- Restart Terminal and try one of the new functions

Obviously you must have TextMate and Coda installed for this to work. Likewise, there are more robust ways to achieve this. However, I like using shell functions in .profile, so that I have only one place to look for customizations when migrating to a new Mac.

More robust implementation approaches can be found for each command at:

My next tips will be some über-handy apps for Finder, allowing you to easily open the Terminal with the current Finder window as the working directory or to easily drag-and-drop to open files in a preferred editor.