Track your dotfiles and homedir configurations in git using GNU Stow
September 12, 2013
I recently discovered the awesome GNU Stow application (works on unix-like systems like GNU/Linux or Mac OSX). Stow is a symlink manager, that allows you to easily deploy and remove files to or from a directory.
Setup
Let’s say you have some configuration files in your home directory (eg: .bashrc
, .vimrc
and a config directory .vim
) and you want to have them in git to be able to track your changes and such. It’s not a really good idea to make your whole home directory a git repo. That’s where Stow comes in. Just create a configuration directory, for instance ‘dotfiles’, and create a subdirectory for every app you have configs for. Then place the appropriate files into the right subdirectory, like this:
/home /{user} /dotfiles /vim .vimrc /.vim ... /bash .bashrc
You can now make the dotfiles directory a git repository, and keep your dotfiles safe in git. But they’re not yet in the right place, so we’ll ask our symlink manager to fix that for us.
Create symlinks
cd
to the dotfiles directory- You can make Stow symlink the files to your homedir like so:
stow {package}
where you replace {package} with the name of the subdirectory you created earlier. - If you now want to remove a certain package’s config files, just do this:
stow --delete {package}
How to install Stow
On Mac OSX
Use Homebrew:
brew install stow
On GNU/Linux
Install stow using your favorite package manager, e.g.:
apt-get install stow
That’s it!
December 7, 2013 at 11:47 pm
This is really awesome and works like a charm on my Mac OS X and Arch linux systems.