Managing dotfiles with stow

linux command line productivity

GNU stow wasn't originally designed to manage dotfiles, but it is an excellent tool for doing just that.

Just create a folder, for example dotfiles, and the usual git init to create a new repository. This will be your base folder to keep all your config files, and by using a repository, it affords easy backups of your set-up.

For example, to add vim to your dotfiles repository, try the following:

mkdir -p ~/dotfiles/vim
mv ~/.vimrc ~/dotfiles/vim/
cd ~/dotfiles
stow vim

The process, as described in the steps above, is to move your current config file (in this example .vimrc) to a subfolder in your dotfiles repository, and stow vim will symlink that file back to your home folder.

What stow is doing here is simply to create a link between ~/dotfiles/vim/.vimrc to ~/.vimrc.

If your application has multiple files within subfolders, this is the same process, but you also create the folders within your dotfiles folder, for example ~/dotfiles/.config/mutt and stow mutt will link the entire folder so you can manage all of your mutt files in one go. Important: If you do this for mutt, just be careful to not include any passwords or sensitive information in your repository.

Published on 2020-05-16