Today, I’ve been adjusting chezmoi to match my workflow for editing dotfiles.
You may be interested to read my previous post where I go over how to setup and use chezmoi: Dotfiles management using chezmoi - How I Use Linux Desktop at Work Part5
The workflow I’m seeking:
Right now, I need to remember not to run chezmoi apply to prevent loosing changes.
Implementing my workflow is not easily supported by chezmoi:
chezmoi has an option to specify the mergetool:
This has the first issue listed above: kdiff3 is called with files in the wrong order
Here is my step process to solve this problem
I could have contributed a change to chezmoi to get this working (and I may will), but I need a solution now.
So I choose to create a script in ~/.local/bin/ called kdiff3merge:
and modify my ~/.config/chezomi/chezmoi.toml:
note: ~/.local/bin is in my path
Now, when calling chezmoi merge ~/.zshenv I get a good result:
Now I just accept the automatically merged changes by saving the changes and closing kdiff3.
One issue I’ve found with this is it creates a dot_zshenv.orig file corresponding to the chezmoi controlled file before the change was applied. I don’t need these since I use version control.
Now orig files are gone.
This is what I needed to fix the first chezmoi limitation I found.
Chezmoi has couple of commands that gives information about changes:
Both commands are actually too verbose. I could not find a way to just print the list of files to bring in.
Obviously, I ended up creating an alias that does this:
If we deconstruct this command:
Problem solved. I regularly run the cmm alias to bring my changes in chezmoi.
chezmoi supports that off the shelf and can be enabled with the chezmoi.toml:
CLI tools offer quick ways to extend or customize to fit your habits.
That being said, my scripts may break at any chezmoi release update.
I just cloned the chezmoi repo, and looking to contribute more permanent changes to chezmoi diff and chezmoi merge commands. This will be a good opportunity to learn go.
This is day 16 of my #100DaysToOffload. You can read more about the challenge here: https://100daystooffload.com.