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.

installbrew · script · apt
flowinit · add · apply
source~/.local/share/chezmoi
installinit + addapply on new PC

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 at chezmoi.io. Run chezmoi --version after install.

Installer chezmoi

  1. 1
    macOS (Homebrew)

    brew install chezmoi. Verify with which chezmoi and chezmoi --version.

  2. 2
    Linux

    Official installer: sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin, then put $HOME/.local/bin on PATH. Distro packages are listed on chezmoi.io.

  3. 3
    First init

    chezmoi init creates 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 push

chezmoi 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 update

Run chezmoi diff before chezmoi apply so you see what will overwrite live files.

Restaurer sur un nouvel ordinateur

  1. 1
    Install chezmoi

    Same brew or get.chezmoi.io steps as above.

  2. 2
    Init your source

    chezmoi init https://github.com/YOUR_USER/dotfiles.git. Private repos need SSH or HTTPS credentials already configured.

  3. 3
    First apply

    chezmoi apply -v. Dry-run first: chezmoi apply -nv. Drop -n once the diff looks right.

  4. 4
    Stay in sync

    chezmoi update pulls and applies; local changes go back via chezmoi re-add or edit, commit, and push.

vs rsync manuel ou Git nu dans ~

ApproachMulti-machinePermissions / templates
Manual cp / rsyncEasy to miss filesYou track it
Git in home onlyWorks; easy to leak secretsNo built-in templating
chezmoiinit + apply / updateadd, 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.

Ouvrir