Happy Tuesday!
all posts

Edit remote files with Sublime Text (over SSH)

Published on Nov 23, 2014

Sven Pachnit GitHub Twitter StackOverflow

If you love vim (or emacs) mor than Sublime just stop reading right here!

Wouldn't it be nice to edit remote files with Sublime sometimes? Well you can! There are just 3 things to do!

1. Install rsub package

Fire up your Sublime and install the package called rsub. If you don't know what I'm talking about refer to Package Control - Usage.

2. Forward port over SSH

You could forward the port manually as well but we want it convenient, right?

Edit your local SSH config with subl ~/.ssh/config and add the following. Note that you can use a hostname instead of * but unless you have port collisions I see no reason to do it.

Host *
  RemoteForward 52698

3. Install rsub script on all servers

A little drop of bitterness here. The magic requires a little helper script on the remote side. I hope this isn't a showstopper, luckily it's just a bash script and is installed as easy as

curl https://raw.githubusercontent.com/aurora/rmate/master/rmate > /usr/local/bin/rsub 
chmod +x /usr/local/bin/rsub

4. Have fun!

Want to edit or show a remote file? Just type rsub my-file.txt into your remote SSH session and wait for the magic to open up the file right there in your local Sublime.