-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manage only part of config file via chezmoi to exclude ovewriting program temporary state settings #847
Comments
The source of described problem is KDE software principes, so I fill feature request to fix this in their thread, but they will not fix this quicker in all programs, so solution from |
I am also in favour of such feature. In my use case, I want to control a few specific lines (which can be selected by regex, regardless of whether it is before or after modification) in a configuration file and I don't care about the rest of the file. I do not want to put the whole file under version control because it changes frequently, and updating the repository every time the file changes (which is every time the application is opened) would be very tedious. In the current version, the solution would probably be to use scripts to be run with I imagine this could be solved, for example, by being able to define a shell script which takes the current version of the file in Are there any plans on supporting this? Thanks in advance. |
This is a really interesting proposal. How does something like the following sound in practice? If a file in the source state has the name An example |
For what it's worth, I'd love for chezmoi to support this - it just needed a good mechanism. |
This is exactly what I had in mind. I would also consider placing an additional restriction on the script, that is to disallow any side-effects like creating additional files. The script should act as a simple filter to ensure that Chezmoi knows what will be modified.
That would be great. Unfortunately, I don't know anything about the inner workings of Chezmoi to suggest a good mechanism to do this, nor am I a Go developer to offer any help. Thanks for considering this feature. |
OK, I'll try to come up with an implementation of this. It will be in chezmoi2 (see #987) as chezmoi2's architecture makes it much easier to add functionality like this.
In practice, this is really hard to implement. chezmoi could spin up an isolated environment (e.g. a Docker container) to run the script, but in the short term I'll just trust the user to make sure that their |
Yes, this is what I meant. The no-side-effects requirement, just as the idempotence, is left solely to the user's responsibility. I don't think this is a problem, because it is stated clearly in the documentation. Running a Docker container to check that all these requirements are met seems like an overkill to me. |
@twpayne great thanks for implementing! But I can't find right documentation how to make new And will be cool to see some example in docs, eg script for enforcing the Meta+D hotkey to show desktop into
|
Currently you have to manually create This is a new feature, and it's clearly not easy to use (see the comments in #1046 for examples), so it's deliberately not documented in detail as we (the chezmoi users) still need to work out how to use it effectively. I think that once we have a few solid examples we can add those to the "how to" documentation. |
@MurzNN FYI I've added a Python script example that would do exactly this — pass all lines of a config file as is except for a single line with an option that matches our regex ("font_size" in my example), which should be tracked vs. our value in a template |
Is your feature request related to a problem? Please describe.
Many programs store config settings (permanent configuration options) and program state settings (temporary settings like window size and position, list of opened files, etc) in one config file, so on each program start and on usage time file is changed very frequently. And each
chezmoi update
rewrite this file to original content, that's bad for UX.Describe the solution you'd like
To solve this problem will be good to have ability to store and apply only part of config file via chezmoi.
Maybe this can be solved via some pre-formatted comment lines like:
Or maybe anybody can provide some better solution?
Describe alternatives you've considered
Alternative solution to described problem, limited only to ini-style config files, can be creating chezmoi function to force set of ini option to needed value, like in SaltStack or other big global configuration management systems.
Additional context
Popular example of this problem is KDE Konsole program, that save window size in his ini-formatted config file
.config/konsolerc
, here is example:So I want to manage and apply via chezmoi only
[Desktop Entry]
,[TabBar]
and[TabBar2]
groups of settings, and don't touch (and always overwrite) other groups.The text was updated successfully, but these errors were encountered: