Opening files on the Raspberry Pi in TextMate
I love working with text on my Mac; I tend to write large documents in iA Writer and code with TextMate 2 or Xcode, which for me, is a very pleasing experience all round—having recently bought a Raspberry Pi I wanted to extend the awesome into that world too. However, as you may already know, TextMate is a Mac only product—but I have found a way, a really nice way, to work with text files on my Pi in TextMate and it’s called: RMate.
Connect to your Raspberry Pi over SSH:
$ ssh pi@<Pi IP Address>
Ruby is preinstalled installed on the Wheezy OS for the Pi, which we need for the next step, but if Ruby is not present on your device, then install it first:
$ sudo apt-get install ruby1.9.1
Install the rmate gem:
$ sudo gem install rmate
Disconnect from remote server and connect again by using a reverse SSH tunnel:
$ ssh -R 52698:localhost:52698 pi@<Pi IP Address>
Navigate to a folder, and then open a file (obviously pick a folder and file you have on your file system, as you probably won’t have these exact ones, unless you’ve been spying on me!):
$ cd ~/Code/www
$ rmate app.js
If all is well, the file will open on your Mac in TextMate.
The only tricky bit for me was the reverse SSH tunnel; but that’s only because it’s not something I’ve done before—otherwise, it’s a pretty simple thing to get working—the first number is port to use on the Pi, the second are the return address and port—52698 is default port supported by TextMate.
It’s also worth pointing out that this approach will work with any remote Linux server, it does not have to be a Raspberry Pi—I’ve now used this technique on a number of servers very successfully; I hope you do too.