2015-03-15

Edit file remotely with Sublime Text

Sublime Text is a great editor for local files. But what if I want to edit files remotely on the other machine under ssh? Like edit my project files on Raspberry Pi using Sublime Text on local machine.

First, (on local machine)
install rsub by Package Control in Sublime Text.

Second, (on RPi)
$ sudo apt-get install ruby
$ sudo gem install rmate

Install rmate on RPi.

Third, (on local machine)
$ ssh -R 52698:localhost:52698 rpi_user@rpi_host
Connect to RPi and forward port rpi_host:52698 to localhost:52698

Fourth, (on RPi)
$ rmate to_be_edited_file
Then the file will open in Sublime Text in local machine.

[1] https://github.com/henrikpersson/rsub
[2] https://github.com/textmate/rmate

[Update]
For convenient use, add following to ~/.ssh/config
RemoteForward pi_host:52698 localhost:52698
Then no need to add -R while using ssh command
Post a Comment