A few days ago I came across the solution to a workflow issue I had been for long wishing could be done. Today I solved another one, and since they’re connected, I outline them below. Maybe they’ll make someone’s day! 🙂
I often work with remote servers that are almost always some flavor of Linux, most frequently Ubuntu/Debian, but also CentOS/Redhat. Despite of being a lifelong geek, I really dislike
vi, finding it massively unintuitive. Maybe I haven’t figured out its intricacies, but I doubt it – it just doesn’t jive with me. In the 90’s I remembered most of Emacs’ chords by heart (or more likely by muscle memory), and really enjoyed using it, but for some reason I eventually stopped using it and only now am picking it up again. For now, however, my go-to editor in Linux is
joe, which is handy enough (more so than
nano), but none of them still are as comfortable and flexible to use than a good GUI editor. In Windows & macOS my editor of choice is Sublime Text 3, and a few days ago I came across this answer in StackOverflow. Enter rmate/rsub! Download, and put on path the small rmate executable on the server, and add few lines in
~/.ssh/config on your Mac (Windows users, keep reading, you haven’t been forgotten):
RemoteForward 52698 127.0.0.1:52698
To exclude some domains where you’ll never use
rsub, like GitHub:
(the significant line above is
rsub package in Sublime (easiest done with Package Control), and now
rsub someFileName command on the remote opens
someFileName in Sublime in Mac! Like magic!! No having to mess with FTPS. Just one word of caution.. if you put the Mac to sleep, the “rsubbed” file may become disconnected from the remote, so when you make the first save after resuming work, verify that the changes are indeed saved, or close the file and reopen it from the remote.
rsub also works with Sublime in Windows. The only part of the above setup that differs on Windows is the SSH config since Microsoft’s effort to create a native OpenSSH port for Windows is slow going (“non-production ready pre-release v0.0.17.0” with 161 open issues as of writing of this post). I usually use VanDyke’s SecureCRT as the SSH terminal in Windows, but I haven’t found a way to forward the rsub port in it correctly. However, it works well with [free] PuTTY, see: Sublime Text, PuTTY, and You.
So far so good (remote editing works great!). Today I needed to diff an old configuration file against the new one, and the CLI
diff output was too tedious to decipher. Then it occurred to me that maybe it would be possible to somehow use my favorite GUI diff utility, Beyond Compare with Sublime — and it is! The only thing to note is that when you open Beyond Compare from the files open in Sublime, you’ll need to save the completed diff first in Beyond Compare, and then in Sublime. Note that the file change indicator doesn’t light up in Sublime even when it has received the changes resulting from the diff reconciliation in Beyond Compare. The changes are received on save in Beyond Compare, but not saved from Sublime until you do so.
Now.. the files opened in Sublime from a remote using
rsub can be diffed by this method with Beyond Compare! Working with remote files just became a lot more fun! 🙂