.dotfile management

Software

One of the defining feautures of *nix is that all your user-specific configuraiton is contained in dotfiles in your home directory. With a bit of care to make them POSIX or portable, one could use the same dotfiles on FreeBSD, macOS, illumos/Solaris, and Linux.

A lot of us keep our dotfiles in repos; partly to version control them, but also because it makes installing them on a new system super easy. I’m sure everyone has a flavour of the following script somewhere:

#!/bin/sh
    
linkneil() {
    if [ -f ~/.$1 ]; then
        echo "$1 already exists."
    else
        ln -s $(pwd)/$1 ~/.$1
        echo "Linked $1, like a boss."
    fi
}
    
linkneil kshrc
linkneil profile
linkneil oksh_completions
linkneil vimrc
linkneil ...
    
case $(uname) in
    Darwin)
        linkneil shuttle.json ;;
    NetBSD)
        linkneil cvsup ;;
esac

The linkneil function creates a symlink to the corresponding file in the repo folder where the script is run. It warns about files that are already there, so I don’t clobber existing files inadvertently. Then the case statement adds OS-specific files.

An adventurous friend of mine back in the day had his git repo set to his home directory, and used .gitignore with a wildcard, then listed the specific dotfiles he was after. He claimed this made things easier by not having symlinks everywhere, but he soon realised it was way more trouble than it’s worth. That friend was me, but I’m referring to myself in the third person so people don’t judge me.

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!