First, you need to install the Sublime Text package manager.
To do this, open up Sublime Text, and hit hit the cntrl+p
key binding (or navigate to: Preferences -> Package Control)
When prompted for the search query, type the following: 'Package Control: Install Package'
Press enter, and shortly it should generate a list of plugins that can be installed to Sublime.
Search for the following plugin: 'RemoteOpen' and press enter. This will begin the installation.
Next, we need to configure some settings in our ~/.ssh/config
file, so go ahead and open up your favorite editor (Hopefully Sublime) and add the following code:
Host <hostname / host ip here>
RemoteForward 52698 127.0.0.1:52698
When we create a tunnel via ssh to our desired Host, it will start a session on port 52698, which is what Sublime Text will be waiting on.
This port can be configured from: Preferences -> Package Settings -> rsub -> Settings -- Default, however it is suggested not to do this.
Once you have all the above set up, tunnel into the remote machine you configured previously inside your ~/.ssh/config
file.
We now want to install the remote rsub script, and configure it to be executable. The following code snippet will do this for you:
sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate && chmod +x /usr/local/bin/rsub
Note that if you changed the port in the plugin settings, you need to change the port in the remote script.
Look for line number 56, which will look like port=52698
simply change it to your desired port.
Now, it's as simple as calling the rsub command on a file while on the machine.
Let's test it out with the following code that will generate a file with the text 'Hello, rsub!' and open it inside Sublime on your local machine.
echo 'Hello, rsub!' > tmp.txt && rsub tmp.txt
Same issue for me then meteabogdan ;
It seems the given code requires a
sudo
after the&&
operator.