twpayne / chezmoi

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

Trying to template chezmoi.toml with prompts #2936

Closed alfredopalhares closed 1 year ago

alfredopalhares commented 1 year ago

What exactly are you trying to do?

I am trying to template .config/chezmoi/chezmoi.toml to prompt me the main aspects that differ from machine to machine.

What have you tried so far?

I have tried the following to try and prove the idea, here is a chezmoi.toml.tmpl:

# -*-mode:conf-toml-*- vim:ft=toml

[git]
   autoCommit = false

# {{ $email := promptString "Git email address for the author/committer" -}}
# {{ $name := promptString "Git username for the author/committer" -}}

[data]
    email = "{{ $email }}"
    name = "{{ $name }}"

So far, i have tried this. but so far failing:

-> % chezmoi status --verbose
chezmoi: template: dot_config/chezmoi/chezmoi.toml.tmpl:6: function "promptString" not defined

Where else have you checked for solutions?

Output of any commands you've tried with --verbose flag

-> % chezmoi status --verbose
chezmoi: template: dot_config/chezmoi/chezmoi.toml.tmpl:6: function "promptString" not defined

Output of chezmoi doctor

-> % chezmoi doctor --verbose
RESULT    CHECK                MESSAGE
ok        version              v2.33.1, commit bc4478d84f59ea38084cf7e58b9226278d0e046d, built at 2023-04-07T22:11:28Z, built by Homebrew
ok        latest-version       v2.33.1
ok        os-arch              darwin/arm64
ok        uname                Darwin AlfredoharesMBP.Home 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
ok        go-version           go1.20.3 (gc)
ok        executable           /opt/homebrew/bin/chezmoi
ok        upgrade-method       brew-upgrade
ok        config-file          ~/.config/chezmoi/chezmoi.toml, last modified 2023-04-18T11:06:32+01:00
warning   source-dir           ~/.local/share/chezmoi is a git working tree (dirty)
warning   suspicious-entries   ~/.local/share/chezmoi/dot_config/chezmoi/chezmoi.toml.tmpl
warning   working-tree         ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir             ~ is a directory
ok        umask                022
ok        cd-command           found /bin/zsh
ok        cd-args              /bin/zsh
info      diff-command         not set
ok        edit-command         found /opt/homebrew/bin/nvim
ok        edit-args            /opt/homebrew/bin/nvim
ok        git-command          found /usr/bin/git, version 2.39.2
ok        merge-command        found /usr/bin/vimdiff
ok        shell-command        found /bin/zsh
ok        shell-args           /bin/zsh
info      age-command          age not found in $PATH
info      gpg-command          gpg not found in $PATH
info      pinentry-command     not set
info      1password-command    op not found in $PATH
info      bitwarden-command    bw not found in $PATH
info      dashlane-command     dcli not found in $PATH
info      gopass-command       gopass not found in $PATH
info      keepassxc-command    keepassxc-cli not found in $PATH
info      keepassxc-db         not set
info      keeper-command       keeper not found in $PATH
info      lastpass-command     lpass not found in $PATH
info      pass-command         pass not found in $PATH
info      passhole-command     ph not found in $PATH
info      rbw-command          rbw not found in $PATH
info      vault-command        vault not found in $PATH
info      secret-command       not set

twpayne commented 1 year ago

The config file template needs to be stored in ~/.local/share/chezmoi/.chezmoi.toml.tmpl. See the section in the user guide.

alfredopalhares commented 1 year ago

I found my problem, I have tried that location but it did not work, that was because I already had a copy of the file in dot_config/chezmoi/chezmoi.toml. Thank you for the heads up either way!