Using vars for segment display #6206
Replies: 3 comments 3 replies
-
@speedenator can you illustrate the wanted behaviour using text? What I'm looking for is what it need to print when. |
Beta Was this translation helpful? Give feedback.
-
I'd like to have the red > marker show up when there's a symbol - in the above case, gear or x. When there aren't any symbols, no > should be present, like at the top of the screenshot. How I'm doing this now is in the attached config, and it's pretty ugly IMHO as it brings in logic from the other segments. What I'm hoping to do is set a variable in the previous segments, and then in the > segment, show it if the variable is set (or > 0). |
Beta Was this translation helpful? Give feedback.
-
OK, thanks. The .Segment.Index isn't super helpful unless it refers to whether the previous segments have something in them or not, which would make for a bit of a weird value. If using the config variables don't work, perhaps setting an ENV variables? Thanks, |
Beta Was this translation helpful? Give feedback.
-
I have a powerline10k zsh custom function that prints symbols for root, background jobs, and prev command error. If any of them show, I'd like there to be a separator to the next segment, otherwise don't show a separator.
I'm trying to use the variables from "vars" and then setting them via {{ $var := }}, ala:
{
...
"vars": {
"display_sep": 0
},
"blocks" {[
...
{
"type" "text",
"template": "{{ if ne .Env.OMP_BG_JOBS "0" }}o{{ $display_sep := 1 }}{{end}}
},
...
{
"type: "text",
"template": "{{ if eq .Var.display_sep 1 }} > {{ end }}"
},
...
}
But this isn't working, and I can't change the variable .Var.display_sep. I'm currently using a lot of duplicate logic via .Env vars but ick.
Is there a better way here?
Beta Was this translation helpful? Give feedback.
All reactions