As I’m running an Ubuntu Server in a virtual machine as development test server and I develop on my local environment, I need to keep both repositories in sync.
The easiest way to solve my problem was through the good old rsync. As I’m too lazy to run an rsync command every time before I want to load a page from my test-server, I wanted it to be done automatically when I saved a file.
As Sublime Text 2 is an awesome editor which supports plugins, I started surfing around looking for some examples which I then adapted for my own use..
This is the plugin I now use:
import sublime, sublime_plugin, subprocess
def on_post_save(self, view):
syncProject = “””rsync -avz localpath remotepath &”””
This code is put in a file named RsyncOnSave.py which is saved a folder named RsyncOnSave, in the Packages folder (for OSX thats: ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/). The plugin should automatically be loaded when you (re-)start Sublime Text.
localpath and remotepath obviously are the paths in your case. Note the ampersand at the end of the sync command, which makes sure your editor doesn’t freeze while the command is being executed.
Make sure you’ve put your public ssh-key in the authorized_keys on your server, so you don’t have to give your password when rsyncing.