'( about )

stow

Posted on 06 Sep 2015

Everyone’s got dotfiles, and some of us like to keep ‘em on GitHub. For me, the hardest part with this is getting all of the files in place after I cloned the repo. I had written a hacked up shell script, but it wasn’t really holding up to lots of use. Whenever I added a new file to the repo, it was a giant pain to have to update the install script as well.

Enter stow

I’m not a huge GNU fan1, but they did get something write with this one. stow is a little util that symlinks the files inside a directory to the parent directory (while retaining the tree structure). So, if we take a look at my dotfiles (simplified for sanity)…

/home/ninjacharlie/.dotfiles
├── bin
│   └── bin
│       ├── colortest
│       ├── dm
│       └── ...
├── git
│   └── gitignore_global
├── i3
├── mksh
│   └── .mkshrc
├── README.md
├── shell
│   └── .sh
│       ├── aliases.sh
│       └── funcs.sh
├── tmux
└── vim

… and I want to just symlink my shell configuration files, I can cd to ~/.dotfiles and run:

stow mksh
stow shell

And voilà, I now have my ~/.mkshrc file and ~/.sh/ dir set up and ready to sync.

This utility is useful in any situation where lots of symlinks are flying around. You could use it to symlink the files in ~/bin to /usr/local/bin, or (if you’re a little crazy), you could symlink and track all the files in /etc.

[1] Overengineering and bloated codebases, but there are worse organizations/projects out there (cough chough freedesktop cough cough)