Skip to content

Examples of modifying part of a file with chezmoi #1746

Answered by twpayne
sheldonhull asked this question in Q&A
Discussion options

You must be logged in to vote

modify_ scripts can be anything that can be executed, including a bash script, a Python script, or even a compiled binary if you are so inclined.

If the modify_ script has a .tmpl extension then chezmoi will interpret it as a template before executing the result.

If I understand your usecase correctly, you want to ensure that .envrc contains certain non-sensitive values. As these are non-sensitive, they can be included in plaintext in the modify_ script itself so you do not need to use a template to extract secrets from a password manager.

Something like the following should work in modify_dot_envrc. Warning: I haven't tested this.

#!/bin/bash

# copy the data to modify to a temporary file

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by twpayne
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