Managing your dotfiles with stow

Stow is a programm that allows you to organize your files in folders, called packages. It then allows you to easily link these files in the ancestor of your stow base directory (or any other should you so choose).

$ cd ~/stow # which could totally be a git repository!
$ tree -a
devel/
├── .gitconfig
└── .gitignore_global
shell/
├── .profile
├── .profile.local
├── .bashrc

The above setup shows the stow folder in my home directory (name does not matter). It contains two packages, devel and shell, both containing some files that I want to have in my ~.

Now you run, within the ~/stow/ directory:

$ stow shell

This would leave everything in ~/stow/ untouched, but create links:

.profile -> stow/shell/.profile
.profile.local -> stow/shell/.profile.local
.bashrc -> stow/shell/.bashrc

Why

This has several benefits:

  • all dotfiles under a single folder
  • git-friendly
  • easy to swap different configurations (for example having a shell_osx and shell_linux folder)
  • dotfiles can still easily be edited, you don’t need to think about stow at all
  • if you dont have stow, you can link everything by hand pretty easily

After trying many different solutions for configuration management, this is the one that stuck with me. It provides a good abstraction without taking work or concentration. It uses basic UNIX-tools, you could probably clone stow in a short amount of time if you are just looking for basic functionality.

Ressources