Managing dotfiles using stow
Posted on January 14, 2023
One of my new year’s resolutions was to come up with a sensible way to manage my dotfiles. I evaluated a few solutions and finally settled on GNU stow.
GNU stow is a symlink manager, normally used to manage symlinks to programs
installed in /usr/local/bin
. However, it can also be used to manage symlinks
to configuration files. After a bit of trial and error, I settled to the
following.
- Create a dirctory
~/Dropbox/dotfiles
to store all the dotfiles. - For each package, create a subdictory
package
. - Typically, the configuration files of a package are either stored in
~/.packagerc
or~/.config/package
. Let’s usezsh
andkitty
as canoncial examples of the two cases. - For
zsh
, create a file~/Dropbox/dotfiles/zsh/dot-zshrc
which has the contents of the desired.zshrc
. - For
kitty
, create a file~/Dropbox/dotfiles/dot-config/kitty/kitty.conf
with the desired contents of~/.config/kitty.conf
- Note that in both cases, we have replaced
.filename
or.dirname
bydot-filename
anddot-dirname
.
Then run the command
stow --target $HOME --dotfiles --verbose package
for each package, which creates the appropriate symlinks. That’s it!
Well almost. There is currently a bug in stow, due to which --dotfiles
option does not work with directories. Fortunately, there is an AUR package
show-dotfiles-git
which provides a fix, at least until the fix is merged
upstream.
It can be tedious to link each package one by one. If so, we can stow all packages at once using
find . -mindepth 1 -maxdepth 1 -type d -printf '%f ' | xargs stow --target $HOME --dotfiles --verbose
This entry was posted in OS and tagged stow, dotfile.