twpayne/chezmoi

Feature requeset: Get external from commands

Closed this issue · 5 comments

Is your feature request related to a problem? Please describe.

I was trying to let chezmoi manage something that comes from commands. (bash completions, or process commands like grep jq sed)

Describe the solution you'd like

Add a new external type: command

Describe alternatives you've considered

Create a script, but it won't has features in .chezmoiexternal

Additional context

Not sure if it's a good idea.

Can you write up something that describes what such an external would look like?

[".local/share/bash-completion/completions/chezmoi.bash"]
    type = "command"
    command= "/usr/local/bin/chezmoi"
    args = ["completion", "bash"]
    refreshPeriod = "168h"

That can be done with a regular template and does not need externals.

{{/* private_dot_local/share/bash-completion/completions/chezmoi.bash.tmpl */}}
{{ output "chezmoi" "completion" "bash" }}

For the specific case of chezmoi's shell completions, you can use the completion template function, for example:

{{/* private_dot_local/share/bash-completion/completions/chezmoi.bash.tmpl */}}
{{ completion "bash" }}

However, @halostatue's solution is more generic.

Given the existence of the output template function, I don't think externals from commands are needed, so I'll close this issue. If you find an example where chezmoi's templates are not sufficient, please re-open this issue.