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 zsh

That command:

  • installs chezmoi to ~/.local/bin and 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-add to 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 global autocrlf=true on WSL can’t break them)
  • writes .zshrc, .bashrc, .p10k.zsh, .vimrc, .taskrc and 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 ROODAY

This 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.git

This 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

TaskCommand
Edit a filechezmoi edit --apply ~/.zshrc
Edited a plain file in place, save it backchezmoi re-add (skips templates like .zshrc/.bashrc)
Preview changeschezmoi diff
Pull + apply on another machinechezmoi update
Commit/pushchezmoi cd, then git as usual
Track a new filechezmoi 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.tmpl detects the host type when the repo is initialized and saves it to ~/.config/chezmoi/chezmoi.toml. Right now that’s just isDeck, which is true when /etc/os-release says steamos. 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.
  • .chezmoiignore keeps 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.tmpl and wrap the differing lines in {{ if .flag }} … {{ end }}.