Skip to content

Instantly share code, notes, and snippets.

@simoninglis
Created February 5, 2026 01:54
Show Gist options
  • Select an option

  • Save simoninglis/98d47f3107db65d0a33aa2ecc72bba85 to your computer and use it in GitHub Desktop.

Select an option

Save simoninglis/98d47f3107db65d0a33aa2ecc72bba85 to your computer and use it in GitHub Desktop.
GNU Stow for Dotfiles - Quick Start Examples

GNU Stow for Dotfiles - Quick Start

Examples from GNU Stow for Dotfiles.

Structure

~/dotfiles/
├── bash/
│   ├── .bashrc
│   └── .bashrc.d/
│       ├── 10-aliases.sh
│       └── 20-prompt.sh
├── git/
│   ├── .gitconfig
│   └── .gitignore.global
└── tmux/
    └── .tmux.conf

Each top-level directory is a package. Contents mirror your home directory.

Commands

# Install a package
cd ~/dotfiles && stow bash

# Remove a package
cd ~/dotfiles && stow -D bash

# Install multiple packages
cd ~/dotfiles && stow bash git tmux

# Preview (dry run)
cd ~/dotfiles && stow -n bash

Getting Started

# 1. Create repo
mkdir ~/dotfiles && cd ~/dotfiles && git init

# 2. Move first config
mkdir bash && mv ~/.bashrc bash/ && stow bash

# 3. Verify
ls -la ~/.bashrc  # should show symlink

Files to Ignore

Create .stow-local-ignore in any package (Perl regex):

^README\.md$
^\.git

What Stow Doesn't Do

  • Secrets management
  • Machine-specific configs
  • Templating
  • Package installation

For those, see the next article on Ansible + Stow.

# ~/.bashrc - sourced by bash for interactive shells
# This file lives at ~/dotfiles/bash/.bashrc
# Source all fragments from .bashrc.d/
if [ -d "$HOME/.bashrc.d" ]; then
for file in "$HOME/.bashrc.d"/*.sh; do
[ -r "$file" ] && source "$file"
done
unset file
fi
# ~/.gitconfig - Git configuration
# This file lives at ~/dotfiles/git/.gitconfig
[user]
name = Your Name
email = you@example.com
[core]
excludesfile = ~/.gitignore.global
editor = nvim
[init]
defaultBranch = main
[pull]
rebase = true
[alias]
st = status
co = checkout
br = branch
ci = commit
lg = log --oneline --graph --decorate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment