I have already blogged about managing KDE dotfiles with chezmoi and chezmoi_modify_manager. But what about maintaining them?
For example, one of the KDE configuration files changes, and you want to update the version managed by chezmoi.
Here’s an example where the Kate configuration file changed on the system and chezmoi detects that:
|
1 2 |
❯ chezmoi status MM .config/katerc |
You can see the change with “chezmoi diff”:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
diff --git a/.config/katerc b/.config/katerc index 3a67fa38f0ba021369d48ace9803e4f7f2e55657..17d7ffff36b8526c4ab14f03942e8a14c64c19d3 100600 --- a/.config/katerc +++ b/.config/katerc @@ -201,7 +201,7 @@ Legend=false LineNumbers=false [UiSettings] -ColorScheme=BreezeDark +ColorScheme=Breeze Dark [filetree] editShade=74,55,117 |
Remember that the part with “+” is the version known by chezmoi, while the one with “-” is the version in the local system.
You now want to update the corresponding file managed by chezmoi.
The command “chezmoi re-add” won’t help because that file is handled by chezmoi_modify_manager, which splits it into two files: “modify_private_katerc” and “private_katerc.src.ini”.
The latter contains only the parts of the file we want to track, and the former is the corresponding modification script.
Moreover, “chezmoi merge” won’t help either for the same reason. Here’s what this command shows (I configured chezmoi to use the GUI program “meld” for such a command):
However, “chezmoi_modify_manager” has an option for such situations. Here’s the option to use with “chezmoi_modify_manager”:
|
1 2 |
-s, --smart-add Smartly add a file to be tracked by either chezmoi or chezmoi_modify_manager |
Here’s the command and the output:
|
1 2 3 4 5 |
❯ chezmoi_modify_manager -s ~/.config/katerc State: Managed by chezmoi and is a modify script. Action: Updating existing .src.ini file for /home/bettini/.local/share/chezmoi/dot_config/modify_private_katerc. Has existing modify script, parsing to check for filtering... Writing out file data |
By using “chezmoi cd” and “git diff”, we can verify that the corresponding “.src.ini” file has been correctly updated (and the git repository can then be committed and pushed):
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
diff --git a/dot_config/private_katerc.src.ini b/dot_config/private_katerc.src.ini index 8e5db59..a54672b 100644 --- a/dot_config/private_katerc.src.ini +++ b/dot_config/private_katerc.src.ini @@ -193,7 +193,7 @@ Legend=false LineNumbers=false [UiSettings] -ColorScheme=Breeze Dark +ColorScheme=BreezeDark [lspclient] AllowedServerCommandLines= |
In the end, it’s easy, once you know the right option to use with “chezmoi_modify_manager”!
Enjoy your KDE dotfiles! 🙂

Pingback: Managing KDE Dotfiles with Chezmoi and Chezmoi Modify Manager | Lorenzo Bettini