GNU Stow Symlink farm manager

Version 2.4.1 · source

Start here

stow <pkg>
Link a package into the parent dir
stow -n -v <pkg>
Dry run, show what would link
stow -t ~ <pkg>
Link into home
stow -D <pkg>
Remove the links
stow -R <pkg>
Relink after changes
stow -d <dir> <pkg>
Use another stow dir
stow --adopt <pkg>
Pull existing files in
stow --dotfiles <pkg>
dot-bashrc becomes .bashrc

Concepts

  1. Stow dir ~/dotfiles
  2. Package vim/.vimrc
  3. Target dir ~/.vimrc

Stow and unstow

stow <pkg>...
Link packages (default action)
stow -S <pkg>
Explicit stow action
stow -D <pkg>
Delete a package's links
stow -R <pkg>
Restow: unlink then link again
Also cleans up links to files you removed from the package.
stow -n <pkg>
Simulate, change nothing
stow -v <pkg>
Verbose output (repeat up to -vvvvv)
stow --verbose=<n> <pkg>
Set verbosity level 0-5
stow -D <old> -S <new>
Mix actions in one run

Directories

stow -d <dir> <pkg>
Set the stow directory
stow -t <dir> <pkg>
Set the target directory
stow -t ~ <pkg>
Link into your home directory
STOW_DIR=<dir> stow <pkg>
Stow dir from environment
stow --dir=<dir> --target=<dir> <pkg>
Long form of -d and -t

Dotfiles and conflicts

stow --dotfiles <pkg>
Turn dot- prefix into a leading dot
stow --adopt <pkg>
Move existing target files into package
Overwrites package content with the target's version. Review with git diff and restore with git checkout.
stow --no-folding <pkg>
Link files, never whole directories
stow --override=<regex> <pkg>
Take over paths owned by another package
stow --defer=<regex> <pkg>
Skip paths already stowed elsewhere

Ignoring and config

stow --ignore=<regex> <pkg>
Skip names ending in a Perl regex
~/.stowrc
Default options, one per line
./.stowrc
Per-directory default options
.stow-local-ignore
Per-package ignore patterns file
~/.stow-global-ignore
Ignore patterns for all packages
stow -V
Print version
stow -h
Show command syntax

Tree folding

Folding behaviour
Situation Result
Target dir missing One symlink to the whole directory
Target dir already real Links go inside it, file by file
Second package needs folded dir Symlink split into real dir, both linked
Package removed, one left Directory refolded to one symlink
--no-folding Always file-level links

Recipes

First-time dotfiles setup
mkdir -p ~/dotfiles/vimmv ~/.vimrc ~/dotfiles/vim/.vimrccd ~/dotfiles && stow -nv vimstow vim
New machine
git clone <url> ~/dotfilescd ~/dotfilesstow -nv bash vim git   # check conflictsstow bash vim git
Adopt existing configs safely
cd ~/dotfiles && git status   # must be cleanstow --adopt vimgit diff                       # see what was adoptedgit checkout .                # keep repo version
Install software under /usr/local
cd /usr/local/stowsudo stow -v <pkg-1.0>sudo stow -D <pkg-1.0>