I often have trouble setting up my PC when I get a new one, or after reinstallating my operating system. I had my perfect setup in place and everything worked as it was supposed to, but now I have to go around hunting for the programs that I want to use and start setting up the configuration again.
Maybe you had similar problems before, maybe not (good for you then!). But I found a handy tool, that takes care of the configuration management aspect of this whole ordeal at least.
The tool I am talking about is GNU Stow, if you’ve heard of it you’re awesome, and if not don’t worry, I’ll give you a quick rundown. There have been many great videos and posts about stow, and it has very comprehensive documentation, but I did not find the 2 minute tl;dr version of Stow yet, so here goes:
What it does
Stow helps you automatically set up and manage symlinks. If you have a folder structure with files (a ‘package’ in stow speak), it can symlink these to a target, and it will automatically make sure to merge everything neatly with existing files. It also takes care of symlink removal for you if you decide that you want to uninstall a package later. If you call stow on a directory like so,
stow dir, then the directory to stow to defaults to the parent of the working directory.
So if you’re in
~/.dotfiles and have a package vim which contains your vim-config, then you just type
stow vim, and it puts your
.vimrc as a symlink in your home directory. If you have a more complicated config in a nested folder structure, that is no problem at all.
You can probably see how convenient this can be if you combine this with a version control system like git and host your dotfiles on an online service.
For your convenience I have summarized a few cli-flags below. Even though I mostly make do without any flags at all.
-t to set the target directory
-D for deleting (unstowing) the stowed symlinks
-R to restow (unstow and stow again), this helps when you deleted some files and want to remove the orphaned symlinks
--dotfiles automatically renames the symlinks of files that start with ‘dot-‘, so that they start with ‘.’