LinuxCommandLibrary

chezmoi

Manage dotfiles across multiple machines

TLDR

Setup up chezmoi, creating a Git repository in ~/.local/share/chezmoi

$ chezmoi init
copy

Set up chezmoi from existing dotfiles of a Git repository
$ chezmoi init [repository_url]
copy

Start tracking one or more dotfiles
$ chezmoi add [path/to/dotfile1 path/to/dotfile2 ...]
copy

Update repository with local changes
$ chezmoi re-add [path/to/dotfile1 path/to/dotfile2 ...]
copy

Edit the source state of a tracked dotfile
$ chezmoi edit [path/to/dotfile_or_symlink]
copy

See pending changes
$ chezmoi diff
copy

Apply the changes
$ chezmoi -v apply
copy

Pull changes from a remote repository and apply them
$ chezmoi update
copy

SYNOPSIS

chezmoi command [options] [arguments]

PARAMETERS

--config=
    Path to the configuration file. Default: ~/.config/chezmoi/chezmoi.toml

--destination=
    The destination directory. Default: your home directory.

--source=
    The source directory. Default: ~/.local/share/chezmoi

--verbose
    Enable verbose output.

--dry-run
    Perform a dry run, showing what would be done without actually doing it.

--apply
    Apply changes to the destination directory.

DESCRIPTION

chezmoi is a powerful tool for managing your personal configuration files (dotfiles) across multiple machines. It allows you to keep your configuration consistent and up-to-date, even when you're working on different operating systems or environments. Unlike simple symlinking or copying dotfiles, chezmoi uses a source directory containing your desired configurations and a target directory (typically your home directory) where it creates and manages the actual dotfiles.

chezmoi allows you to use templates in your dotfiles, meaning you can generate configuration files that adapt to each host with specific values. This allows creating dynamic configurations.

It leverages a secure, encrypted store to hold sensitive information that should not be stored in a public git repository, and it integrates with popular password managers. chezmoi can also be used to manage system configurations, not just user dotfiles.

CAVEATS

chezmoi heavily relies on version control (typically Git) to manage the source directory. It's crucial to understand Git basics to effectively use chezmoi. File names can be changed with special meaning

WORKFLOW

The typical chezmoi workflow involves using the `chezmoi add` command to add existing dotfiles to the source directory. Files are renamed to a standard format (with a .tmpl if templating is used). Then `chezmoi apply` is used to materialize the files from the source directory to the destination. Files can be easily updated with the `chezmoi edit` command.

SECRETS MANAGEMENT

chezmoi integrates with password managers such as Bitwarden, 1Password, and LastPass. You can use secret variables in your templates and chezmoi will automatically retrieve the values from your password manager when applying changes.

HISTORY

chezmoi was created by Tom Payne to solve the problem of managing dotfiles across multiple machines. It has gained popularity for its flexible templating system and secure storage of secrets. Development is actively maintained and supported by a growing community.

SEE ALSO

git(1)

Copied to clipboard