Skip to content

claude .TokenUsagePercent doesn't work with background_templates? #7299

@ahmetb

Description

@ahmetb

Code of Conduct

  • I agree to follow this project's Code of Conduct

What happened?

I'm observing color template statements like {{ if gt .TokenUsagePercent 50 }} don't work at all.
I think the Go template is correct because {{ if gt 100 50 }} works just fine.

Repro:

- type: claude
  style: diamond
  powerline_symbol: 
  trailing_diamond: 
  template: " Context: {{ .TokenUsagePercent }}%/{{ .ContextWindow.ContextWindowSize }}"
  foreground: "#f8f8f8"
  background: "#273c75"
  background_templates:
    - "{{ if gt .TokenUsagePercent 50 }}#eccc68{{ end }}"
    - "{{ if gt .TokenUsagePercent 70 }}#ff6348{{ end }}"
    - "{{ if gt .TokenUsagePercent 85 }}#ff4757{{ end }}"

Version: 29.1.0 (latest).

Theme

N/A – config provided above

What OS are you seeing the problem on?

macOS

Which shell are you using?

zsh

Log output

attached below

Metadata

Metadata

Labels

🐛 bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions