Playing around with rmate on TextMate 2.0 beta

I’ve always been a huge fan of TextMate and it was my go-to text editor on Mac for years. I slowly stopped using it when I started my previous job as I never really used my Mac for work purposes anyway. Now that I’m back at university, I’ve had a look at a bunch of text / code / all-purpose editors and decided to try out TextMate 2.0 beta, and so far I’m loving it. What I really love is this feature:

Remote mate

In the past, TextMate has suffered with editing files on a server, but that’s all changed now. If you regularly find yourself SSHed into a remote box and wanting to edit a file using TextMate on your own box, your ship has come in.

TextMate 2 now ships with an rmate (Ruby) script that you can drop onto servers. When you trigger rmate on a remote box, it will connect back to your box, allow you to edit, and update the file on the server with the changes.

(Find out more about rmate on the MacroMate website, including detailed installation and usage instructions.)

This is a great feature as lately I’ve been editing a lot of files on my RaspberryPi, so being able to work with these files locally on my Mac in a powerful editor like this is a huge bonus and something you definitely don’t get with nano. I know there are terminal text editors more powerful than nano out there, but the rmate feature is really great.

In order to get rmate working, you must first verify that you have TextMate set up to accept rmate connections. This is done through the Terminal preferences pane. Make a note of the default port (52698) or note down the port you are changing it to, as you will need it later.

In order for rmate to work, we have to initiate a reverse SSH session to the remote RaspberryPi:

$ ssh -R 52698:localhost:52698 pi@myRaspberryPi

From there, you can install rmate via gem on the remote server:

$ sudo gem install rmate
Fetching: rmate-1.5.7.gem (100%)
Successfully installed rmate-1.5.7
1 gem installed
Installing ri documentation for rmate-1.5.7...
Installing RDoc documentation for rmate-1.5.7...

That’s it! We can now use rmate to edit remote files. In order to test this:

$ rmate helloworld.txt

In order to easily connect to your remote server, I suggest adding an alias to your .bash_profile. In order to do this, open up your .bash_profile (usually ~/.bash_profile) and enter the following:

alias matessh="ssh -R 52698:localhost:52698 pi@myRaspberryPi"

That’s just one of the cool features, but I’m sure I’ll discover plenty more as I start using TextMate more often again. TextMate also just replaced all other writing apps on my Mac too – I just love its simplicity and power, including my half-a-dozen Markdown editors I’ve been trying.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s