My dotfiles setup

Published: 2011, May 29 | Comments

For a quite long time I wanted to clean up my dotfiles hanging around on different machines having different OS- and host-specific quirks to make sure there is smooth environment on any (Unix-like) machine I ever touch, so if I work on something I could concentrate on what I am working on, not on having different screen or less settings.

Beside having dotfiles adapted for different OSes I also wanted to avoid lot of clutter lying around, like Emacs configs on headless router I never intend to run Gnus on.

Couple of months ago ago I finally had a time and desire to do it (mostly due to fact I had to use Mac OS X for more than browsing Web and reading PDFs (and OS X is pretty damn good for those two tasks, BTW)), so I bit the bullet and scratched simple dotfiles manager, which allows me apply subset of configuration files checked out from repository on selected machine.

The way I use it is as the following:

  • I check out my dotfiles from git repository to ~/.dotfiles
  • I think what dotfiles "profiles" make sense on this machine
  • I run ~/.dotfiles/applyprofiles profile1 profile2
  • Every file in selected profile gets a symlink from $HOME back to it

You can see the list of profiles in my git repository. Each profile is just the list of files usually hanging in $HOME:

~/.dotfiles $ ls -aR basic
basic:
.  ..  bin  .screenrc  .zshenv	.zshrc

basic/bin:
.  ..  downloadit  ssh
~/.dotfiles $

And applying this profile creates symlinks that point back to the ~/.dotfiles:

~ $ ls -a
...
lrwxrwxrwx .zshenv -> .dotfiles/basic/.zshenv
lrwxrwxrwx .zshrc -> .dotfiles/basic/.zshrc
...

If I am setting up a machine for a OS or version I never used before I adjust my dotfiles locally and push the changes back to the git (my .zshrc nudges me every time I start a new shell if there any uncommitted changes in repository).

On the other machines I do a git pull and run ~/.dotfiles/applyprofiles in order to set up new symlinks if the need arises.

This setup works pretty much fine for a couple of months, the only hosts I didn't use it yet are Solaris ones, with non-POSIX #!/bin/sh. Fortunately I don't spend too much time on Solaris.