Remote Editing for TextMate

This page describes some remote editing scripts I use with the TextMate editor for the Mac.

Note: I've had some comments that the ODBForwarder, and hence these scripts, don't work with Leopard. I hope to look into it, but I'm not sure exactly when I'll get around to it. Until then, people might like to look at Mac FUSE and sshfs.

Download

The remote editing scripts are available here.

Installation

This set of scripts and programs is distributed as a tar file. It can be uncompressed with the command: tar zxf RemEdit.tgz

You should then have the following files inside the unpacked directory:

You should install these as follows:

You will also need to run the command:

defaults write org.dyndns.wuther.ODBforwarder ODBEditor com.macromates.textmate

to tell ODBForwarder to use TextMate rather than its default of BBEdit. That command will need to be run before you try any of the scripts. Otherwise you should log out and log back in to restart ODBForwarder.

Usage:

The purpose of these scripts and programs is to allow TextMate to edit files on remote machines. This is achieved by copying the remote files to local temporary storage, letting TextMate edit them, and then copying them back whenever TextMate saves its changes. All the copying is achieved using scp. You'll need to have scp set up with key-based login so that a password is not required to connect from your mac to the remote machine. I highly recommend SSHKeyChain for this.

There are three different methods provided for telling TextMate which remote file to open:

Justification:

All of these scripts are a little rough right now - but they are certainly useful. Patches are welcome if you clean any of it up - willu.sp@cse.unsw.edu.au .

The goal is to add something like the sftp functionality in BBEdit to TextMate.

So, why did I make my own system rather than just using Transmit, Cyberduck, or one of the other FTP programs that works with TextMate?

Technical Details

These scripts work as follows. When asked to open a file they create a temporary local directory. The remote file is copied across to that local directory using scp. As well as that local copy of the file for TextMate to edit, a backup copy is made so we can check to see if we accidentally missed any edit events, and some data about the location on the remote machine for the file is stored. TextMate is then asked to edit the local file using the odbedit command (which then uses ODBForwarder.app). The odbedit command will ask any ODB aware editor (of which TextMate and BBedit are both examples) to open a file, and can then call supplied scripts when the file is edited or closed. In this case, the scripts copy the modified file back to the remote machine when it is changed. The local directory is removed when the file is closed in TextMate.