Skip to content

Full examples of modifying part of a file with chezmoi #3996

Answered by bradenhilton
jmlucjav asked this question in Q&A
Discussion options

You must be logged in to vote

When using a modify_ script, the contents of the file are no longer managed in the "traditional" way by chezmoi. Put simply, chezmoi just feeds the current contents of the file to the script via stdin, and uses its stdout to set the new contents of the file.

If you have changes you want to propagate, this would need to be done with the script itself, not the file.

You might want to explore using template functions such as fromIni, toIni, setValueAtPath, deleteValueAtPath etc. if you require something more robust than simple pattern replacements.

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@bradenhilton
Comment options

@jmlucjav
Comment options

@bradenhilton
Comment options

Answer selected by jmlucjav
@jmlucjav
Comment options

@bradenhilton
Comment options

@jmlucjav
Comment options

@twpayne
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants