stow
Manage symbolic links for dotfiles
TLDR
Symlink all files recursively to a given directory
Delete symlinks recursively from a given directory
Simulate to see what the result would be like
Delete and resymlink
Exclude files matching a regular expression
SYNOPSIS
stow [-d directory] [-t target] [-n] [-v level] [-S] [-D] [-R] [-L] package ...
PARAMETERS
-d directory
Specify the directory where packages are located. Defaults to the current directory.
-t target
Specify the target directory where packages will be installed. Defaults to the parent directory of the package directory.
-n
No-op mode: print actions without executing them.
-v level
Set verbosity level (0-3). Higher values provide more detailed output.
-S
Stow only. Create symbolic links.
-D
Delete only. Remove symbolic links and empty directories.
-R
Restow. Equivalent to -D followed by -S.
-L
Lazy stow. Do not delete any stale symlinks in the target dir unless another package needs to claim them.
package
The name of the package directory to be installed.
DESCRIPTION
The stow command is a utility for managing the installation of software packages within a directory tree. It achieves this primarily through the creation of symbolic links. The core idea is to keep different packages separate in their own subdirectories, and then use stow to link the files from those subdirectories into a common target directory (typically /usr/local or /opt).
This allows for easy installation, uninstallation, and version management of multiple packages without conflicts. It is particularly useful for managing dotfiles, software installed from source, or different versions of libraries. stow simplifies the process of keeping track of which files belong to which package.
It minimizes the need for manual symbolic link management and provides a clean, organized structure for software deployments.
CAVEATS
stow relies on proper directory structure and file organization within the package directories. Conflicting filenames across packages can lead to unexpected behavior or errors. Ensure packages do not overwrite each other's files unless intended.
EXAMPLE USAGE
To install the 'my-package' located in the current directory into /usr/local, use: stow -t /usr/local my-package.
To uninstall 'my-package' run: stow -D -t /usr/local my-package.
COMMON WORKFLOW
A typical workflow involves creating a directory (e.g., 'stow') to hold all the packages, placing each package in its own subdirectory, and then using stow to link the package contents into the target directory (e.g., /usr/local). This allows for easy switching between different versions, uninstalling specific software or custom configuration.
HISTORY
stow was initially designed to manage dotfiles. It has evolved into a general-purpose tool for managing package installations, particularly in environments where package managers are not available or not suitable. Its usage has expanded to managing configurations and deploying custom software builds.