From ecb6c1d98bbe3e3f9de7951680bb975b1266b536 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Mon, 29 Nov 2021 23:35:28 +0000 Subject: [PATCH] feat: Add .chezmoi.configFile template variable --- docs/REFERENCE.md | 1 + internal/cmd/config.go | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 9e6ec884035..c6781bedd6b 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -1891,6 +1891,7 @@ chezmoi provides the following automatically-populated variables: | -------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------- | | `.chezmoi.arch` | `string` | Architecture, e.g. `amd64`, `arm`, etc. as returned by [runtime.GOARCH](https://pkg.go.dev/runtime?tab=doc#pkg-constants). | | `.chezmoi.args` | `[]string` | The arguments passed to the `chezmoi` command, starting with the program command. | +| `.chezmoi.configFile` | `string` | The path to the configuration file used by chezmoi, if any. | | `.chezmoi.executable` | `string` | The path to the `chezmoi` executable, if available. | | `.chezmoi.fqdnHostname` | `string` | The fully-qualified domain name hostname of the machine chezmoi is running on. | | `.chezmoi.group` | `string` | The group of the user running chezmoi. | diff --git a/internal/cmd/config.go b/internal/cmd/config.go index b3cda30b83d..e6ebd1d38ea 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -930,6 +930,7 @@ func (c *Config) defaultTemplateData() map[string]interface{} { "chezmoi": map[string]interface{}{ "arch": runtime.GOARCH, "args": os.Args, + "configFile": c.configFileAbsPath.String(), "executable": executable, "fqdnHostname": fqdnHostname, "group": group,