UP | HOME

Dot files with GNU Stow

GNU/Stow is a handy little utily designed to symlink programms built from source to their correct place which makes it easier to keep track of them.

However it's also a very handy tool if you want to backup your config files with a version control system like git, because it allows you to store all your config files in one folder. In addition you can collect the configuration files from all of your machines in that folder because you can just symlink the ones you need and forget about the rest.

Creating the stow directory

To use stow you simply need to move your dot files to a central folder. E.g. dotfiles. In the that folder you have to create a folder for each configuration you want to store E.g.:

  • VLC
  • Vim
  • Bash

In each folder you have to replicate the folder structure of your home directory. For VLC this would mean the following path -> VLC/.config/vlc For Bash -> Bash/ The config files have to be in the "same" folder like they normally would.

A more visual comparison:

Structure of the Home folder

home/
    andreas/
        .config/
        .vim/
            [...some files]
        .bashrc
        .bash_profile
        .bash_logout
        .vimrc

Structure of the stow diretory

dot_files/
    bash/
        .bashrc
        .bash_profile
        .bash_logout
    vim/
        .vim/
            [...some files]
        .vimrc

Backing up the files

The easiest way to back up the config files is with a git repository. This has the advantage of being able to see the changes and the comments why a certain config file is the way it is.

Restoring the config files

To link the files you can execute:

stow application_name

This will link the structure to the parent folder. However since we want to restore them to the home folder we have to specify the target folder.

In my case the command then looks like this:

stow -t /home/andreas/ application_name

To make it easier to restore multiple applications I put everything into a shell script. In addition it allows me to easily specify different configurations for different machines.

Resources