Handling configuration transformations #2657
Replies: 1 comment 4 replies
-
I’ve changed this into a discussion, because I think that it would be an interesting concept to explore. The difficulty that would be present is indicating what the transformation mechanisms would end up looking like. At least some of this could probably be done now as your file:
The As a note, your script could be simplified some by using Back to your original idea, though, some sort of Some of this would lean toward to ideas that @bradenhilton originally suggested for template substitutions. Maybe there’s a transforms:
private_dot_config/Typora/profile.data:
encode: jq -S -c $source | xxd -p -c0
decode: xxd -r -p $target | jq -S . That way, your |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I'm wanting to store the configuration for an application, but the format its stored in is hex encoded JSON. Ideally I would like to be able to have chezmoi track the JSON, but then when applying the changes, have it transform it into the required format. This way it's easier to manage.
I currently have it working by modeling it after the example in https://www.chezmoi.io/user-guide/use-scripts-to-perform-actions/#clear-the-state-of-run_once_-scripts via:
But wanted to bring this up to see if there's either a better existing way to handle this, or maybe is room for a new feature to better handle it.
Describe the solution you'd like
Basing a solution off of typora/typora-issues#2353 (comment), I was thinking of having some sort of
transform_
prefix script. Like it would allow havingprofile.data
in the source state with the JSON contents. Then if you had another filetransform_profile.data
it would pass the contents ofprofile.data
to the script, and write its output to the target'sprofile.data
file. This way it keeps the contents and the transformations separate.Describe alternatives you've considered
Is possible that the
run_once_
script approach is fine. The> $HOME/.config/Typora/profile.data
part just felt a bit hacky.Additional context
I don't feel too strongly about my proposed solution, so feel free to close if its not something worth adding.
Beta Was this translation helpful? Give feedback.
All reactions