Named Segments
#1969
Replies: 1 comment
-
The answer to .Code wasn't to make it global in oh-my-posh (that's already the case), but from the PowerShell logic. Mixing and matching segments template properties can be done, colors is something we need to severely rework. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was thinking it would be useful if you could name a segment so you could then check that segment for properties in other segments.
Let's say for instance you have an exit segment and you want to have another segment change it's color based off of the exit segments code. If it was named you could maybe do something like:
"{{ if gt .Name.exit.Code 0 }}red{{ else }}green{{ end }}
Or if you want to copy the color of another segment you could use
.Name.segmentName.foreground
Something like a global map/dictionary that stores named segments so you can access their properties. And you don't have to check the map if the variable .Name isn't present. I previously made a post about exit codes for the transient prompt and the response there was to potentially make .Code global. I feel in this way you could make all segment values accessable without having to globalize them.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions