Как установить chezmoi: init, add dotfiles и apply на новом компьютере

Dotfiles в Git-источнике chezmoi; новая машина — init и apply.

Новый ноутбук 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. Материал: установка macOS/Linux, chezmoi init, add dotfiles, edit/diff, первый apply на новой машине для читателей 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

Что решает chezmoi

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.

Установка 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.

Добавление файлов

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 и команды

chezmoi apply
chezmoi diff
chezmoi status
chezmoi update

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

Восстановление на новом ПК

  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 или Git в ~

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
Подходит
Several Mac/Linux machines, shared shell/editor/SSH setup, clear Git history for dotfiles.
Не подходит
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.

После настройки — схема на доске

Once terminal and editor settings match, service boundaries still belong on a shared canvas. See как создать пространство.

Начать