Remote Editing with TextMate
TextMate does not have a save over sftp function, and I'm not sure Allan has any plans to add it in. Sometimes it's useful to edit files remotely. I often run my development server on another (faster) machine and do the actual editing on my trusty old (now slightly slow) PowerBook.
Solution
The solution is fairly rudimentary and simple but it works:
create a TextMate project. Create a real TextMate project rather than temporary one as we will want to save some project variables.
setup your project variables.
setup two project variables
$TM_REMOTE_SERVER. Set this to something likekeith@servername:$TM_REMOTE_SERVER_PORT. Set this to 22 unless you have your ssh access setup over some other port
create a snippet or better still, create a new bundle called something like "Remote Editing" and then a new snippet in that bundle. The snippet code:
if [ "$TMREMOTESERVER" != "" ] then scp -P{$TMREMOTESERVERPORT#22} -oStrictHostKeyChecking=no $TMFILEPATH $TMREMOTESERVER$TM_FILEPATH fi
Have the snippet save the current file, output as a tooltip and set its key equivalent to
APPLE-s. It should all look something like this:
One limitation of this system is that the directory structure on both local and remote machines needs to be the same. It would be possible to address this issue, but mirroring my directory structures for projects I want edit remotely has not been a big deal for me. Basically you setup a /User/UserName/projects dir on each machine and everything is ok.
You also need to have ssh public key authentication and an ssh-agent (like SSH Chain) running so that the scp happens without asking for a password.
