Loading blogs…
Tools4 min read
Keep your .bashrc, .zshrc, git, Neovim and terminal configs in one git repo and symlink them anywhere with GNU Stow — set up a new Linux machine in minutes.
Full-stack engineer, New Delhi
"Dotfiles" are the hidden config files in your home folder — .bashrc, .gitconfig, ~/.config/nvim and friends. Over time they become years of small improvements. Losing them with a laptop, or recreating them by hand on every server, is painful. The fix is simple: keep them in a git repo and let GNU Stow symlink them into place.
There are dozens of dotfile managers. Stow wins because it's tiny, boring and has been around for decades. It does one thing: for each folder in your repo, it creates symlinks in your home directory that mirror the folder's structure. No config language, no magic.
sudo pacman -S stow # or: sudo apt install stow
mkdir ~/dotfiles && cd ~/dotfiles
git initEach top-level folder is a "package". Inside it, recreate the path relative to your home directory:
~/dotfiles
├── bash
│ └── .bashrc
├── git
│ └── .gitconfig
├── nvim
│ └── .config
│ └── nvim
│ └── init.lua
└── kitty
└── .config
└── kitty
└── kitty.confmkdir -p bash git nvim/.config
mv ~/.bashrc bash/
mv ~/.gitconfig git/
mv ~/.config/nvim nvim/.config/From inside ~/dotfiles:
stow bash git nvimStow creates ~/.bashrc → ~/dotfiles/bash/.bashrc and so on. Edit the file in either place — it's the same file — and commit when you're happy.
Useful flags:
| Command | What it does |
|---|---|
stow -n -v bash | Dry run: show what would happen |
stow -D bash | Remove that package's symlinks |
stow -R bash | Restow (after adding files) |
stow --adopt bash | Pull existing files into the repo, then link them |
--adopt is handy on a new machine that already has default configs — but it overwrites the repo copy with the local file, so check git diff afterwards.
git add .
git commit -m "Initial dotfiles"
git remote add origin git@github.com:you/dotfiles.git
git push -u origin maingit clone https://github.com/you/dotfiles.git ~/dotfiles
cd ~/dotfiles
stow */ # every package at onceAdd a small install.sh that installs your packages too, and a fresh Arch install goes from bare console to "my machine" in one command:
#!/usr/bin/env bash
set -euo pipefail
sudo pacman -S --needed - < packages.txt
cd "$(dirname "$0")" && stow */Generate packages.txt from your current machine with pacman -Qqe > packages.txt.
Dotfiles repos are often public. Never commit API tokens, SSH private keys or .netrc. Two habits help:
[ -f ~/.secrets ] && . ~/.secrets.gitignore in the repo for anything sensitiveIf you ever push a secret by accident, rotate it — deleting the commit isn't enough, because it may already be cloned or cached.
Keep one shared .bashrc and source a local override at the end:
[ -f ~/.bashrc.local ] && . ~/.bashrc.localThe local file stays out of git, so your work laptop and home desktop can differ without branches or templating tools.
That's the whole system. It takes twenty minutes to set up and saves you every time you touch a new computer.
Tools
ripgrep, fd, bat, eza, fzf, zoxide and more — faster, friendlier replacements for grep, find, cat and ls, with install commands and config.
Terminal
Keyboard shortcuts, history tricks, brace expansion, xargs and more — practical Bash and Zsh tricks that make you much faster in the terminal.
Linux
Use ed25519 keys, ~/.ssh/config shortcuts, jump hosts and port forwarding like a pro — then harden your server's SSH daemon.