一键导入
chezmoi-init
Bootstrap chezmoi on a new machine, clone an existing dotfiles repo, migrate existing dotfiles, or run one-shot init scripts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Bootstrap chezmoi on a new machine, clone an existing dotfiles repo, migrate existing dotfiles, or run one-shot init scripts.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Write chezmoi templates: OS/machine conditionals, user-defined data variables, Sprig functions, shared fragments, and interactive prompts.
Run scripts on apply, once, or on content change — manage run_, run_once_, run_onchange_, run_before_, and run_after_ scripts and their state.
Configure chezmoi behavior: source/target dirs, data injection, encryption, editor, diff/merge tools, git auto-commit, and operation hooks.
Integrate with password managers (Bitwarden, 1Password, etc.) and manage encrypted files using age or gpg.
Work with the chezmoi source directory: file naming prefixes, adding/removing files, externals (.chezmoiexternal for external files, archives, and git repos), special directories (.chezmoiignore, .chezmoitemplates/), and git operations.
Look up and run chezmoi commands: add, apply, diff, status, update, verify, edit, merge, re-add, state, and other core operations on the target directory.
| name | chezmoi-init |
| description | Bootstrap chezmoi on a new machine, clone an existing dotfiles repo, migrate existing dotfiles, or run one-shot init scripts. |
See references/setup.md for more details.
chezmoi init
Creates the source directory at ~/.local/share/chezmoi as a git repository.
If the source directory contains a .chezmoi.$FORMAT.tmpl file, generates the config file from that template.
Does not apply any files — run chezmoi apply separately.
Re-running chezmoi init with no repo regenerates the config file (e.g. after editing the config template).
chezmoi init https://github.com/user/dotfiles.git
Use --apply to clone and apply in one step:
chezmoi init --apply https://github.com/user/dotfiles.git
Use --purge to remove the source, config, and cache directories after applying (useful for ephemeral environments):
chezmoi init --apply --purge https://github.com/user/dotfiles.git
Use --one-shot for transitory environments (e.g. containers) — equivalent to --apply --depth=1 --force --purge --purge-binary:
chezmoi init --one-shot user/dotfiles
chezmoi init user # https://user@github.com/user/dotfiles.git
chezmoi init user/myrepo # https://user@github.com/user/myrepo.git
chezmoi init gitlab.com/user/myrepo # https://user@gitlab.com/user/myrepo.git
Pass --ssh to guess SSH URLs instead (git@github.com:user/dotfiles.git), or --guess-repo-url=false to disable guessing.
See references/commands.md for the full pattern table.
--source, --destination, and --config are global flags, not init-specific — see the chezmoi-cli-commands skill.
Init's own -C/--config-path flag writes the generated config file to a different location.
chezmoi init --source ~/.dotfiles
chezmoi init --config-path /path/to/chezmoi.toml
To persist a custom source directory, set the sourceDir config option (see the chezmoi-configuration skill).
See references/commands.md for full init flag details.
Install chezmoi, clone the repo, and apply in a single command:
sh -c "$(curl -fsLS https://get.chezmoi.io)" -- init --apply user/dotfiles
For transitory environments, use --one-shot to also remove all traces of chezmoi afterwards:
sh -c "$(curl -fsLS https://get.chezmoi.io)" -- init --one-shot user/dotfiles
If a target file has been modified since chezmoi last wrote it, chezmoi apply prompts before overwriting.
Preview changes with chezmoi diff, overwrite without prompting with chezmoi apply --force, or merge with chezmoi merge <file>.
To incorporate existing dotfiles into chezmoi:
chezmoi add ~/.bashrc ~/.gitconfig
chezmoi init --source ~/.dotfiles
This overrides the source directory for chezmoi commands. It does not set up a bare repository.
Then migrate files using chezmoi add.
chezmoi doctor # check for problems
chezmoi data # confirm template data loaded
chezmoi diff # preview what would be applied
chezmoi managed # list managed files
To reset and start over (destructive):
chezmoi purge --binary # removes source dir, config, and chezmoi binary
chezmoi init # start fresh