Manage dotfiles using chezmoi This note was created on 11/5/2020 This note was last edited on 1/31/2023 "chezmoi" helps you manage your personal configuration files (dotfiles, like ~/.bashrc) across multiple machines. It has strong support for security, allowing you to manage secrets (e.g. passwords, access tokens, and private keys) securely and seamlessly using a password manager of your choice or GnuPG encryption. Source code available at GitHub: https://github.com/twpayne/chezmoi. === Installation === You can install "chezmoi" using your package manager or by runnig the following command: > curl -sfL https://git.io/chezmoi | sh This will install correct binary in "./bin". === Upgrading === If you have installed a pre-built binary of chezmoi, you can upgrade it to the latest release with: > chezmoi upgrade === Basic usage === - Initialize chezmoi repository: > chezmoi init This will create a new git repository in "~/.local/share/chezmoi" with permissions 0700 where chezmoi will store the source state. chezmoi only modifies files in the working copy. It is your responsibility to commit changes. - Manage an existing file with chezmoi: > chezmoi add ~/.bashrc This will copy "~/.bashrc" to "~/.local/share/chezmoi/dot_bashrc". Use "-r" to add whole folder. - Edit source state of configuration file: > chezmoi edit ~/.bashrc This will open "~/.local/share/chezmoi/dot_bashrc" in your $EDITOR. - See what changes will be made: > chezmoi diff - Apply changes to actual dotfiles: > chezmoi -v apply Add "-v" for verbose output and "-n" for dry run. - Restore dotfiles on another machine: > chezmoi init https://gitlab.com/username/dotfiles.git > chezmoi apply - Launch a shell in the source directory: > chezmoi cd - List the managed files in the destination directory: > chezmoi managed - Remove a target from the source state (stop managing): > chezmoi forget ~/.bashrc - Pull latest changes from repository: > chezmoi update === Read more === "chezmoi" have much more functionality. Read more on the official website: https://www.chezmoi.io/docs/how-to.