No New Messages
author avatar
Syed Reza
1536223672859 | NOTE

Managing Dotfiles

A few months ago I finally decided to use more than one computer.

I've always gravitated towards having one machine for most of my personal work. It saves me the trouble of configuring multiple machines, syncing things, and etc.

In making this change to using two development machines, I needed a way to keep some config files in sync. This appears to be a common problem among programmers.

I considered using Chef or some other configuration manager but such an approach felt too heavyweight for the handful of files I wanted synced.

I ended up writing a small Ruby script for the task. It firstly pulls the latest version of itself via git from GitHub. It looks at a folder with two top level folders, one called __HOME__ which contains and represents files relative to the home directory of the host machine. The other is called __ROOT__ for files relative to root.

It takes this folder and creates symlinks to the intended location. In the process if some file are to be overwritten, it creates a backup of the target file.

Lastly, it records the symlinks that are created. On future runs, it looks for any broken links previously created and removes them.

You can find this script on GitHub in my Dotfiles repository.

I'll try to generalize it in the near future.

I hope it is of some use to someone out there.