How do I set variables? #4271
-
Here is my {{ if eq .chezmoi.hostname "personal-pc" }}
systemContext = "home"
{{ else if eq .chezmoi.hostname "work-pc" }}
systemContext = "work"
{{ else }}
systemContext = "server"
{{ end }} I've also tried to add this to the But when I run either
And as you can see it wasn't added as a variable. $ chezmoi data | jq .systemContext
null I'm very new to Go templating syntax, and so I appreciate the help. |
Beta Was this translation helpful? Give feedback.
Answered by
Lockszmith-GH
Feb 12, 2025
Replies: 1 comment 1 reply
-
This is an example I use: {{- $sysname := promptStringOnce . "sysname" "System name" -}}
{{- $sysgroup := promptStringOnce . "sysgroup" "System group" -}}
{{- $sysarea := promptStringOnce . "sysarea" "System area" -}}
{{- $gitEmail := promptStringOnce . "gitEmail" "email address (for git commits)" -}}
{{- $gitName := promptStringOnce . "gitName" "Full name (for git commits)" -}}
[data]
{{- if ($sysname) }}
sysname = {{ $sysname | quote }}
{{- end -}}
{{- if ($sysgroup) }}
sysgroup = {{ $sysgroup | quote }}
{{- end -}}
{{- if ($sysarea) }}
sysarea = {{ $sysarea | quote }}
{{ end -}}
{{ if ($gitEmail) }}
gitEmail = {{ $gitEmail | quote }}
{{- end -}}
{{- if ($gitName) }}
gitName = {{ $gitName | quote }}
{{- end }}
[diff]
# command = "nvim"
# args = ["-d", "{{- "{{ .Destination }}" -}}", "{{- "{{ .Target }}" -}}"]
command = "delta"
args = ["--paging=never", "{{ "{{ .Destination }}" }}", "{{ "{{ .Target }}" }}"]
pager = "delta" If what you posted was your complete file, then you are missing the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
lkdm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an example I use: