Transient prompt arrow color change lags by one line #5404
-
When attempting to set the transient prompt arrow color to change from green to red when an error occurs, the first command always shows as green (the default color) even for commands that error, and the following commands always show the arrow color the previous command should have had. Here is my # :schema https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
version = 2
final_space = true
console_title_template = '{{ .Shell }} in {{ .Folder }}'
# Defining Color Palette
[palette]
my_blue = '#4B82FA'
white = "#F8F9FA"
black = "#000000"
l_blue = "#8DBFE7"
d_blue = "#3171BE"
purple = "#968AC6"
l_purple = "#A092D9"
pink = "#C370B9"
# Defining Left Block
[[blocks]]
type = 'prompt'
alignment = 'left'
newline = true
[[blocks.segments]]
type = 'os'
style = 'diamond'
leading_diamond = '╭─'
template = ' {{ if .WSL }}WSL at {{ end }}{{.Icon}} '
background = 'p:l_purple'
foreground = 'p:black'
Text = ''
Duration = 0
NameLength = 0
[[blocks.segments]]
type = 'path'
style = 'powerline'
powerline_symbol = ''
template = ' {{ .Path }} '
background = 'p:my_blue'
foreground = '#111111'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
home_icon = '~'
max_depth = 2
style = 'agnoster_short'
[[blocks.segments]]
type = 'git'
style = 'powerline'
powerline_symbol = ''
background_templates = [
'{{ if or (.Working.Changed) (.Staging.Changed) }}#c4a000{{ end }}',
'{{ if and (gt .Ahead 0) (gt .Behind 0) }}#f26d50{{ end }}',
'{{ if gt .Ahead 0 }}#89d1dc{{ end }}',
'{{ if gt .Behind 0 }}#4e9a06{{ end }}',
]
template = ' {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} {{ .StashCount }}{{ end }} '
background = '#4e9a06'
foreground = '#000000'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
branch_icon = ' '
fetch_stash_count = true
fetch_status = true
fetch_upstream_icon = true
# Defining Right Block
[[blocks]]
type = 'prompt'
alignment = 'right'
[[blocks.segments]]
type = 'status'
style = 'powerline'
powerline_symbol = ''
invert_powerline = true
background_templates = ['{{ if gt .Code 0 }}#cc2222{{ end }}']
template = ' {{ if gt .Code 0 }}{{ reason .Code }}{{ else }}{{ end }} '
background = 'green'
foreground = 'black'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
always_enabled = true
[[blocks.segments]]
type = 'python'
style = 'powerline'
powerline_symbol = ''
invert_powerline = true
template = " {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}({{ .Venv }}) {{ end }}{{ .Major }}.{{ .Minor }} {{ end }}"
background = '#FA781E'
foreground = '#111111'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
home_enabled = true
display_mode = 'context'
fetch_virtual_env = true
[[blocks.segments]]
type = 'root'
style = 'powerline'
powerline_symbol = ''
invert_powerline = true
template = ' '
background = '#ffff66'
foreground = '#111111'
Text = ''
Duration = 0
NameLength = 0
[[blocks.segments]]
type = 'executiontime'
style = 'powerline'
powerline_symbol = ''
invert_powerline = true
template = ' {{ .FormattedMs }} '
background = '#c4a000'
foreground = '#000000'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
threshold = 5000
[[blocks.segments]]
type = 'time'
style = 'diamond'
invert_powerline = true
trailing_diamond = ''
template = ' {{ .CurrentDate | date .Format }} '
background = '#d3d7cf'
foreground = '#000000'
Text = ''
Duration = 0
NameLength = 0
[blocks.segments.properties]
time_format = "15:04:05"
[[blocks]]
type = 'prompt'
alignment = 'left'
newline = true
[[blocks.segments]]
type = 'text'
style = 'plain'
template = '╰─'
background = 'transparent'
foreground = 'p:purple'
Text = ''
Duration = 0
NameLength = 0
[transient_prompt]
foreground_templates = ['{{if gt .Code 0}}red{{end}}']
foreground = "green"
background = 'transparent'
template = ' '
[secondary_prompt]
foreground = 'magenta'
background = 'transparent'
template = ' ' I've tried searching for similar discussions but couldn't find anything similar. Everything was run in MacOS Sonoma using iTerm2 for the terminal. Any ideas on what could be the cause? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@ErGoVega Unfortunately, that's impossible because a transient prompt is rendered before the command is actually executed. |
Beta Was this translation helpful? Give feedback.
-
Transient is always the prompt before the command is run. So that makes sense. |
Beta Was this translation helpful? Give feedback.
@ErGoVega Unfortunately, that's impossible because a transient prompt is rendered before the command is actually executed.