Struggling to get if .name then change colour to work #4154
Answered
by
JanDeDobbeleer
MarkDarwin
asked this question in
Troubleshoot
|
I have adapted bubblesextra theme but have a problem getting text to change colour. Please can someone suggest a way forward as I've tried a number of options and all seem to result in the text remaining the same colour. Any help wold be gratefully received to save more hair pulling :) {
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#29315A",
"foreground": "#3EC669",
"leading_diamond": "\ue0b6",
"properties": {
"style": "agnoster_short",
"max_depth": 2
},
"style": "diamond",
"template": "\ue5ff {{ .Path | base }}",
"trailing_diamond": "\ue0b4",
"type": "path"
},
{
"background": "#29315A",
"foreground": "#43CCEA",
"foreground_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"leading_diamond": " \ue0b6",
"properties": {
"branch_max_length": 25,
"fetch_stash_count": true,
"fetch_status": true,
"fetch_upstream_icon": true
},
"style": "diamond",
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
"trailing_diamond": "\ue0b4",
"type": "git"
}
],
"type": "prompt"
},
{
"alignment": "right",
"foreground_templates": [
" {{if eq .name \"Production\" }}red{{ else }}green{{ end }}"
],
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#ffa500",
"foreground_templates": [
" {{if eq \"Production\" .name }}red{{ else }}green{{ end }}"
],
"template": " \uebaa "
},
{
"style": "plain",
"template": "{{ .Name }} ",
"foreground_templates": [
"{{ if eq \"Production\" .name }}#ff0000{{ end }}",
"{{ if eq \"Sandbox\" .name }}#208320{{ end }}"
],
"foreground": "#ffa500",
"type": "az"
}
],
"type": "prompt"
}
],
"final_space": true,
"version": 2
} |
Answered by
JanDeDobbeleer
Aug 11, 2023
Replies: 1 comment 1 reply
|
The one in the az segment is in the correct location, however, the property names are case sensitive: |
1 reply
Answer selected by
MarkDarwin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The one in the az segment is in the correct location, however, the property names are case sensitive: