I love simple but powerful tools. Like most of the GNU packages, stow
does one thing and it does it really well. What’s it do? It stows files, of course!
My primary use case for GNU Stow is in my dotfiles, where I use it to install my configuration files all over my $HOME
directory. This humble tool replaced a bunch of home grown installation logic I had written over the years.
No reason to write clever code, if there’s a simple app that can do the heavy lifting for you.
With my recent shake up of my tech stack, I did end up stowing something that I wanted to “unstow”. This isn’t something I do very often, so I fumbled around a bit before finding what I needed in the man pages
.
Undoing a previous stow
Initially thinking in terms of the UNIX Philosophy, I half expected unstow
to be a thing. Sadly, it was not.
Turns out “unstow” isn’t even what they call it. The act of “unstowing” is referred to as deleting. Makes sense, since you’re technically deleting the symbolic links that were previously created.
First off, to delete a previous stow
, you’ll need to be in the same directory in which you did the stow
to begin with. Once you’re there, you need to run stow
again, with the same name, and deletion argument:
# Longhand
% stow --delete packageToUnstow
# Shorthand
% stow -D packageToUnstow
ZshNot much to it, the package that was previously linked is not unlinked and you can go about your business.
Make your own unstow
command
If you did you want to take it a step further, and create an unstow
command, you could simply make an alias:
alias unstow='stow --delete'
ZshEasy enough to do, but not for me since I don’t need to delete stowed packages often.