Keeping Things in Sync with Syncer

Leave a comment

In almost every company where I’ve ever worked as a developer, I’ve had both a personal work computer and a development machine. The development computer may be a virtual machine sitting in a datacenter somewhere or it may be a Dell desktop tucked under my desk next to the file cabinet.

In all cases, I’ve preferred to work on my code locally and sync it with my development machine for testing. This allows me to write code in an off-line mode, and allows me to take advantage of many of the bells and whistles of my IDE.

The process of keeping files in sync between my local and remote computers has always been different, and never ideal… until now.

One of my co-workers recently clued me in to Mac OS X’s File System Events API. This is a low-level OS API that emits events corresponding to very common actions on files, like saving, opening, and closing.

I did some hunting and found this great Ruby script which takes advantage of the API. When the script is running it listens for save events in the current working directory tree and syncs the entire directory tree to a remote location using rsync.

I made some improvements to the script so that it can take command-line options like username, hostname, and a remote directory location. The updated script is available in its own repository from GitHub. Feel free to grab Syncer and play with it.

As it stands right now Syncer makes two assumptions about your operating environment:

  1. You have an ssh-agent running which allows you to connect to your remote server without having to type a password every time. If you don’t already have this, read this great tutorial on ssh-agent. It will tell you everything you need to know.
  2. The script takes advantage of growlnotify, a command-line interface for Growl. growlnotify is an extra in the Growl distribution. So, you need to install it separately.

If you find this script useful let us know.

About Eric

UI Engineer at AppNexus

This entry was posted in Developer Tools. Bookmark the permalink.

Leave a comment