jamesturk.net

personal website of James Turk, a developer in Washington, DC

keeping dotfiles in sync

James Turk — 2010/07/25 — dotstore

If you find yourself logging into 3 or more machines in a given day (for me my laptop, work machine, and a few servers) you've probably faced the problem of being on a machine and not having some essential piece of functionality in your .vimrc or .bashrc alias handy. Maybe you copy the file you need over with scp, but this is never satisfying as it will get out of sync and you can quickly end up with several divergent copies of dotfiles.

I've been looking for a long time for a decent solution for keeping dotfiles in sync and in the last few years have tried both using a VCS and, more recently, Dropbox.

Revision Control

An obvious choice is to keep dotfiles in revision control and then download them on any new machine. Indeed many people do this, although after trying it for a while it is an unsatisfying option.

Pros:

  • versioned history of each file, capability of doing merges, etc.
  • easy to share dotfiles with others

Cons:

  • likely involves symlinking dotfiles to a separate directory to keep under revision control (or tracking entire homedir)
  • have to remember to push new changes
  • if you want to track private files (.gnupg for instance) requires a private git/hg repo set up somewhere all your machines can access

Dropbox

Most of my files are already synced between my desktop, netbook, and notebook using Dropbox so it seems like a logical option to use for my dotfiles, and in fact this is my current solution. There are some issues though:

Pros:

  • all the advantages of dropbox: syncs without any real effort, some undo history
  • entirely private unless you choose to share a particular file, safe to keep sensitive dotfiles

Cons:

  • requires you to store dotfiles in a directory within dropbox (eg. ~/Dropbox/dotfiles) and symlink ~/.dotfile to ~/Dropbox/dotfiles
  • only works on machines that you can install dropbox on, which means with servers you're back to square one

A New Solution

I've been reluctant to introduce a new tool, but lately I've been sketching out what such a tool might look like and I think there's a way to do this the right way.

Imagine a program named dotstore that exposes the following UI:

chochacho$ dotstore login
Username: james.p.turk@gmail.com
Password: *******
Wrote dotstore token to .dotstore

chochacho$ dotstore add ~/.vimrc
Added file ~/.vimrc
chochacho$ dotstore add ~/.bashrc
Added file ~/.bashrc

and on a second machine:

ramses$ dotstore login
Username: james.p.turk@gmail.com
Password: *******
Wrote dotstore token to .dotstore

ramses$ dotstore status
  ? ~/.vimrc
  ? ~/.bashrc
ramses$ dotstore sync
  downloaded .vimrc
  downloaded .bashrc
ramses$ vim ~/.vimrc         # make edits
ramses$ dotstore status
  * ~/.vimrc
ramses$ dotstore sync
  pushing new ~/.vimrc

and of course, back on the first machine the changes to .vimrc could be retrieved:

chochacho$ dotstore status
  ^ ~/.vimrc
chochacho$ dotstore sync
  stored ~/.vimrc is newer than local: (d)iff (k)eep (u)pdate: u
  replacing local ~/.vimrc with remote ~/.vimrc
chochacho$ dotstore status   # no output, copies are in sync

Looking over the pros and cons from before, with a little work this system could provide the best features from both and avoid the whole symlink dance. It'd be trivial to add a way to share dotfiles too (perhaps a --public flag on add and a site to browse the files people have shared). Figuring out a way to (optionally) have changes be automatically reflected might be the hard part, but even without automatic syncing typing 'dotstore sync' is arguably a lot easier than having to maintain a system of symlinks, etc.

I'm already working on building a prototype to see if it is good enough for my own use cases, but in the meantime I wanted to put this out there to see if others thought it might be a useful service. Also, comment below if you'd like to help test the server and client once I get them running.

edit: I've started up a parallel discussion on reddit

blog comments powered by Disqus

about james

James Turk is a 23 year old currently living in Washington, DC working for Sunlight Labs. This site is a place for my projects and thoughts.

content © James Turk — cc-by unless otherwise noted