twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.4k stars 493 forks source link

Chezmoi Config templates should have access to default data #326

Closed jakeswenson closed 5 years ago

jakeswenson commented 5 years ago

I would like to be able to use default data to build my chezmoi config. Right now i have a template like:

[data]
    name = "Jake Swenson"
    email = "...."
    is_work = {{if eq .chezmoi.username "jakes_work_user" }}true{{else}}false{{end}}

but when config templates are applied default data is not available: https://github.com/twpayne/chezmoi/blob/master/cmd/init.go#L116

Seems like it should be possible to add default config data to this template init call. https://github.com/twpayne/chezmoi/blob/master/cmd/config.go#L341

twpayne commented 5 years ago

Great spot, thank you :)