Skip to content

How to get rid of percentage sign from template execution? #2491

Answered by halostatue
dhruvinsh asked this question in Q&A
Discussion options

You must be logged in to vote

The % is not part of the output.

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 hostnamectl):

$ chezmoi execute-template '{{ (output "echo" "{\"Chassis\": \"vm\"}" | mustFromJson).Chassis  }}'
vm%
$ chezmoi execute-template '{{ (output …

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@dhruvinsh
Comment options

@dhruvinsh
Comment options

Comment options

You must be logged in to vote
2 replies
@halostatue
Comment options

@dhruvinsh
Comment options

Answer selected by dhruvinsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants