Installer chezmoi : init, add dotfiles et apply sur un nouvel ordinateur
Versionner les dotfiles avec chezmoi ; nouvelle machine : init + apply.
Nouveau portable or a fresh OS install means copying ~/.zshrc, SSH config, and editor settings by hand. chezmoi keeps dotfile sources in Git: chezmoi add on the machine you use today, chezmoi init plus chezmoi apply on the next one. Ce guide couvre installation macOS/Linux, chezmoi init, ajout de dotfiles, edit/diff, premier apply sur un nouvel ordinateur pour les lecteurs de hereink.
The query is how to install chezmoi manage dotfiles and apply on a new machine. You should finish with chezmoi installed, a initialized source tree, at least one config file under management, and a successful apply after cloning your source elsewhere.
Ce que chezmoi règle
Versioned dotfiles
Track ~/.gitconfig, shell rc, ~/.config/nvim, and friends in one Git repo instead of ad hoc backups. Changes diff cleanly and roll back across machines.
Templates and secrets
chezmoi supports templates (OS-specific paths) and pulling secrets from 1Password and similar—so you do not commit live tokens. Start with plain add, then move edits to chezmoi edit.
Upstream:
github.com/twpayne/chezmoi, docs atchezmoi.io. Runchezmoi --versionafter install.
Installer chezmoi
- 1macOS (Homebrew)
brew install chezmoi. Verify withwhich chezmoiandchezmoi --version. - 2Linux
Official installer:
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin, then put$HOME/.local/binonPATH. Distro packages are listed on chezmoi.io. - 3First init
chezmoi initcreates the source tree under~/.local/share/chezmoi. If you already host dotfiles on GitHub:chezmoi init https://github.com/YOUR_USER/dotfiles.git.
Ajouter des fichiers existants
Paths in the source are relative to home. To manage your current ~/.zshrc:
chezmoi add ~/.zshrc
chezmoi cd
git status
git commit -m "Add zshrc"
git pushchezmoi add copies into the source with permissions preserved. After that, change configs with chezmoi edit ~/.zshrc (edit source, then apply to home) so home and source do not drift.
Apply local et commandes courantes
chezmoi apply
chezmoi diff
chezmoi status
chezmoi updateRun chezmoi diff before chezmoi apply so you see what will overwrite live files.
Restaurer sur un nouvel ordinateur
- 1Install chezmoi
Same brew or get.chezmoi.io steps as above.
- 2Init your source
chezmoi init https://github.com/YOUR_USER/dotfiles.git. Private repos need SSH or HTTPS credentials already configured. - 3First apply
chezmoi apply -v. Dry-run first:chezmoi apply -nv. Drop-nonce the diff looks right. - 4Stay in sync
chezmoi updatepulls and applies; local changes go back viachezmoi re-addor edit, commit, and push.
vs rsync manuel ou Git nu dans ~
| Approach | Multi-machine | Permissions / templates |
|---|---|---|
| Manual cp / rsync | Easy to miss files | You track it |
| Git in home only | Works; easy to leak secrets | No built-in templating |
| chezmoi | init + apply / update | add, templates, secret hooks |
- Convient
- Several Mac/Linux machines, shared shell/editor/SSH setup, clear Git history for dotfiles.
- Ne convient pas
- Single machine, tiny config, never reinstall—plain backup may be enough.
Edited ~/.zshrc but chezmoi status shows drift?
You changed the live file. Run chezmoi re-add ~/.zshrc to capture into source, or chezmoi apply to reset home from source (destroys uncommitted home edits—diff first).
How is this different from GNU stow?
stow symlinks a package tree into home; chezmoi keeps a separate source and applies it, with templates and cross-OS support. Pick one workflow.
Windows?
chezmoi supports Windows with different paths and shells—see chezmoi.io. WSL users often manage Linux home separately from Windows dotfiles.
Après les configs, schématiser le système
Once terminal and editor settings match, service boundaries still belong on a shared canvas. See créer un espace.