diff --git a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml index 1367817f63b..b26fc239910 100644 --- a/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml +++ b/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml @@ -298,6 +298,9 @@ sections: mode: default: '`cache-password`' description: See [KeePassXC functions](../templates/keepassxc-functions/index.md) + openArgs: + type: '[]string' + description: Extra args to KeePassXC CLI command, after `open` in open mode prompt: type: bool default: '`true`' diff --git a/assets/chezmoi.io/docs/reference/templates/keepassxc-functions/index.md b/assets/chezmoi.io/docs/reference/templates/keepassxc-functions/index.md index 0abba20ad84..2afa823bc2c 100644 --- a/assets/chezmoi.io/docs/reference/templates/keepassxc-functions/index.md +++ b/assets/chezmoi.io/docs/reference/templates/keepassxc-functions/index.md @@ -16,4 +16,5 @@ password prompt can be disabled by setting `keepassxc.prompt` to `false`. By default, chezmoi will prompt for the KeePassXC password when required and cache it for the duration of chezmoi's execution. Setting `keepassxc.mode` to `open` will tell chezmoi to instead open KeePassXC's console with `keepassxc-cli -open`. chezmoi will use this console to request values from KeePassXC. +open` followed by `keepassxc.openArgs`. chezmoi will use this console to request +values from KeePassXC. diff --git a/internal/cmd/keepassxctemplatefuncs.go b/internal/cmd/keepassxctemplatefuncs.go index 408e063c55a..067eac68fda 100644 --- a/internal/cmd/keepassxctemplatefuncs.go +++ b/internal/cmd/keepassxctemplatefuncs.go @@ -37,6 +37,7 @@ type keepassxcConfig struct { Database chezmoi.AbsPath `json:"database" mapstructure:"database" yaml:"database"` Mode keepassxcMode `json:"mode" mapstructure:"mode" yaml:"mode"` Args []string `json:"args" mapstructure:"args" yaml:"args"` + OpenArgs []string `json:"openArgs" mapstructure:"openArgs" yaml:"openArgs"` Prompt bool `json:"prompt" mapstructure:"prompt" yaml:"prompt"` cmd *exec.Cmd console *expect.Console @@ -198,7 +199,10 @@ func (c *Config) keepassxcOutputOpen(command string, args ...string) ([]byte, er } // Start the keepassxc-cli open command. - cmdArgs := append(slices.Clone(c.Keepassxc.Args), "open", c.Keepassxc.Database.String()) + cmdArgs := slices.Clone(c.Keepassxc.Args) + cmdArgs = append(cmdArgs, "open") + cmdArgs = append(cmdArgs, c.Keepassxc.OpenArgs...) + cmdArgs = append(cmdArgs, c.Keepassxc.Database.String()) cmd := exec.Command(c.Keepassxc.Command, cmdArgs...) //nolint:gosec env := os.Environ() // Ensure prompt is in English.