How to get rid of percentage sign from template execution? #2491
-
> chezmoi execute-template '{{ (output "hostnamectl" "--json=short" | mustFromJson).Chassis -}}'
vm% When I execute above template on one of the VM I get vm%, how can I get rid of the percentage sign here? Because with % sign, I tried but still the same. chezmoi execute-template '{{ trimSuffix "%" (output "hostnamectl" "--json=short" | mustFromJson).Chassis -}}'
vm% at this point I am not sure if % is line ending, but not sure. This config is not working for me. {{/* chassisType variable set to "desktop" or "laptop" or "vm" */}}
{{- $chassisType := (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
[data]
chassisType = {{ $chassisType }} Update: {{/* chassisType variable set to "desktop" or "laptop" or "vm" */}}
{{- $chassisType := (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
[data]
chassisType = {{ $chassisType | quote }} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Doesn't the percent sign just signify the end of the output? https://unix.stackexchange.com/questions/167582/why-zsh-ends-a-line-with-a-highlighted-percent-symbol What are the contents of the config template? |
Beta Was this translation helpful? Give feedback.
-
The You need to do one of the following: {{/* chassisType variable set to "desktop" or "laptop" or "vm" */}}
{{- $chassisType := (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
[data]
chassisType = {{ $chassisType | quote }} or {{/* chassisType variable set to "desktop" or "laptop" or "vm" */}}
{{- $chassisType := (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
[data]
chassisType = "{{ $chassisType }}" You can see the difference here (I don’t use Linux, so I don’t have $ chezmoi execute-template '{{ (output "echo" "{\"Chassis\": \"vm\"}" | mustFromJson).Chassis }}'
vm%
$ chezmoi execute-template '{{ (output "echo" "{\"Chassis\": \"vm\"}" | mustFromJson).Chassis | quote }}'
"vm"% Under fish, this looks like: $ chezmoi execute-template '{{ (output "echo" "{\"Chassis\": \"vm\"}" | mustFromJson).Chassis }}'
vm⏎
$ chezmoi execute-template '{{ (output "echo" "{\"Chassis\": \"vm\"}" | mustFromJson).Chassis | quote }}'
"vm"⏎ Fish is using |
Beta Was this translation helpful? Give feedback.
The
%
is not part of the output.You need to do one of the following:
or
You can see the difference here (I don’t use Linux, so I don’t have
hostnamectl
):