My dotfiles (ROODAY/dotfiles) are managed with chezmoi. One branch covers every machine. chezmoi works out what kind of host it’s on and fills in the right bits. Setting up a new machine is one command.
Linux (Ubuntu/Debian servers, WSL, Steam Deck)
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin init --apply ROODAY
exec zshThat command:
- installs chezmoi to
~/.local/binand clones the repo to~/.local/share/chezmoi - on Ubuntu/Debian, installs zsh, git, taskwarrior, timewarrior, html-xml-utils and the font-awesome fonts with apt, plus Neovim from the official release, and switches the login shell to zsh (sudo will prompt)
- on the Steam Deck, skips system packages (SteamOS’s root filesystem is read-only), so bash hands off to zsh instead
- on WSL, also aliases
ssh/ssh-addto Windows’ssh.exe, so keys come from the Windows SSH agent - clones oh-my-zsh, zsh-autosuggestions, zsh-syntax-highlighting and powerlevel10k, and refreshes them weekly (cloned with
core.autocrlf=false, so a globalautocrlf=trueon WSL can’t break them) - writes
.zshrc,.bashrc,.p10k.zsh,.vimrc,.taskrcand the nvim config
No SSH key is needed, because the repo is public and clones over HTTPS.
Windows
winget install twpayne.chezmoi
chezmoi init --apply ROODAYThis installs Git, Neovim and Windows Terminal with winget if they’re missing, and writes .vimrc, the nvim config (to %LOCALAPPDATA%\nvim), the Windows Terminal settings, and PowerShell profiles that alias vim/v to nvim and cz to chezmoi.
If I want to push changes from this machine
Clone over SSH instead by adding --ssh to the init command, or switch an existing clone:
chezmoi git -- remote set-url origin git@github.com:ROODAY/dotfiles.gitThis needs an SSH key added to GitHub (on Windows, see How to set up SSH Agent on Windows 10+).
Staying up to date
New zsh shells check GitHub in the background about once a day, and print dotfiles: N new commit(s), run cz update when the machine is behind. cz update pulls and applies. Nothing applies automatically.
Day to day
| Task | Command |
|---|---|
| Edit a file | chezmoi edit --apply ~/.zshrc |
| Edited a plain file in place, save it back | chezmoi re-add (skips templates like .zshrc/.bashrc) |
| Preview changes | chezmoi diff |
| Pull + apply on another machine | chezmoi update |
| Commit/push | chezmoi cd, then git as usual |
| Track a new file | chezmoi add ~/.something |
cz is an alias for chezmoi in zsh, bash and PowerShell.
Per-machine differences
These live in the repo as templates, not branches:
.chezmoi.toml.tmpldetects the host type when the repo is initialized and saves it to~/.config/chezmoi/chezmoi.toml. Right now that’s justisDeck, which is true when/etc/os-releasesayssteamos. To override it on one machine, edit that file.- WSL is detected inline from the kernel version string (it contains
microsoft), so it needs no saved flag. .chezmoiignorekeeps the Linux shell files off Windows, and the Windows files off Linux.- To add a new kind of host, add a flag to
.chezmoi.toml.tmpland wrap the differing lines in{{ if .flag }} … {{ end }}.