Read my book

I wrote books about Webpack and React. Check them out!

Sunday, September 2, 2012

Using Dropbox to Sync Your Dotfiles

I bought myself a MacBook Air (13") not long ago and needed some way to sync my files between it and my main system. Apparently Dropbox provides the perfect way to do this. All you need to do is to set up an account over there and symlink!

The basic workflow goes like this:
  1. Copy some dotfile (ie. .bash_profile) to /Dropbox (might want to use some subdir like /dotfiles/bash or something)
  2. Make a backup of the original ("cp .bash_profile .bash_profile.bak"). You might need this later if you screw something up. You should have backups set up in any case, though!
  3. Create a symbolic link to the file at Dropbox ("ln -s Dropbox/dotfiles/bash/.bash_profile .bash_profile" . The command works like this "ln -s source target". Keep that in mind.).
You will need to create this symlink on each system where you want to use the common configuration. After that it will just work and the changes you make to the configuration on any system will propagate to each eventually. You can use the same process for your Vim configuration etc.

Besides doing syncs like this I've been using Dropbox to sync photos and videos from my phone with the service. It is incredibly simple to share your media like this. In addition they provide a nice web based user interface. Nothing is nicer than creating a little video with your phone and then just passing a link to it to your friends to watch.

By the way, if you happen to use Vim, you might want to make sure your swap files won't get synced. Fortunately there is a simple way around this. Weevil Genius suggests the following configuration:

set directory^=$HOME/.vim_swap//   "put all swap files together in one place

Besides Dropbox I use 1Password to keep track of my account details. Incidentally that happens to use Dropbox for syncing as well. One of my favorite publishers, The Pragmatic Bookshelf, provides support for Dropbox sync too.

They give you around two gigabytes of storage on the free plan. That's more than enough for syncing dotfiles. I can see it's not that much if you share media. Fortunately they provide various ways to earn some extra space. If you would like to use the service and donate some extra space for me, go ahead and register using this very link.

I know there are various similar service out there. So far Dropbox has worked well for me. I like particularly the way they've handled integration with various devices. There's no going back once you get used to it.