My dot files, managed by chezmoi
Using on a new machine, after installing chezmoi (I use Ansible)
chezmoi init https://github.com/willquill/dotfiles.gitCheck the diff to verify you aren't overwriting something you want to keep:
chezmoi diffApply the changes:
chezmoi applyPull latest changes from the repo and see what would change without applying:
chezmoi git pull -- --autostash --rebase && chezmoi diffPull latest changes and apply:
chezmoi git pull -- --autostash --rebase && chezmoi applyOn a system using chezmoi, if you want to edit the ~/.gitconfig file, you should be editing the template instead of the file directly.
To edit ~/.local/share/chezmoi/dot_zshrc.tmpl, use the following command:
chezmoi edit ~/.zshrcThis will open your editor to edit the template file that populates ~/.zshrc.
Alternatively, enter the chezmoi directory with this:
chezmoi cdScenario: You like to keep your Starship config in ~/.config/starhip.toml
First, put your file where you want it to be. Then add it to chezmoi.
chezmoi source-path &&\
chezmoi add ~/.config/starship.tomlSee here for documentation
vim ~/.local/share/chezmoi/chezmoiignoreAdd these contents:
README.md
{{- if ne .chezmoi.hostname "work-laptop" }}
.work # only manage .work on work-laptop
{{- end }}This will omit installing the README on all machines and only install .work if hostname is work-laptop.
To make managing chezmoi easier, the templates should, when possible, reference a chezmoi variable (similar to an Ansible fact), for which a key/value pair always exist on every host.
However, you can also have a template use a value that comes from a file on the host. For example, if I want the value of init.templateDir in my git config to be unique per host and for the value to not come from a chezmoi variable, I would need to populate the value within ~/.config/chezmoi/chezmoi.yaml on the host. You can use TOML, JSON, JSONC, or YAML.
Here's an example of me creating and populating the file on a new macOS system:
mkdir -p ~/.config/chezmoi && echo -e "data:\n templateDir: \"/Users/will/.git-template\"" > ~/.config/chezmoi/chezmoi.yamlAlternatively, instead of manually creating the file, see this doc on creating the config file automatically.
And in my dot_gitconfig.tmpl file, I would enter:
[init]
templateDir = {{ .templateDir }}By doing that, the value of templateDir after applying my dot_gitconfig.tmpl file will be /Users/will/.git-template.
The ~/.zshrc will also be generated from a template, but it uses chezmoi variables like os and hostname (see them with chezmoi data) and does not require the chezmoi.yaml file.
chezmoi add ~/.config/kitty/kitty.conf --templateAdd a few base settings and something machine-specific:
# Base Kitty settings
font_family FiraCode Nerd Font
enable_audio_bell no
background #232627
{{ if eq .chezmoi.hostname "spacewalk" }}
# Machine-specific overrides
font_size 10.0
{{ end }}
See a diff:
chezmoi diff ~/.config/kitty/kitty.confApply:
chezmoi applyThe init.templateDir specifies the directory from which template files and directories will be copied when initializing a new repository.
Color theme information found here.
To get the FiraCode Nerd Font with a script, execute the appropriate firacode.sh script for your OS.
- Inspiration from Kevin