Adding a Month Segment to claude-powerline

Adding a Month Segment to claude-powerline

I use claude-powerline for my Claude Code statusline. It’s got a today segment that shows spend since midnight, which is great until you actually want to know where you stand for the month. “Today” resets every night and tells you nothing about the bigger picture. So I sent a PR: Owloops/claude-powerline#112.

What it adds

A new month segment, opt-in, that tracks total cost/tokens for the current calendar month. It reuses the same local-transcript aggregation and caching the today segment already had, so no network calls, nothing new to trust.

The color reacts to spend, too: theme’s normal color under 50% of budget, yellow from there up to a warning threshold (80% by default), red above it. Same pattern the block and weekly segments already used, just applied here. Budget defaults to $500/month so it does something useful without any config at all. There’s also an optional days-remaining-in-the-month stat and a daily-average stat, both plain calendar math.

The moon phase icon

The part I had the most fun with: set icon: "moon" and the segment shows today’s actual lunar phase. No API, no astrology library — just date math against a known reference new moon and the mean synodic month length (29.53 days), accurate to about a day.

Getting the icon right took a few passes:

  1. Color emoji (🌑🌒🌓🌔🌕🌖🌗🌘) — looked great, except color emoji ignore ANSI theme colors entirely. Every other icon in the statusline takes on your theme, this one didn’t, and it stuck out.
  2. A plain monochrome 4-phase indicator (○◖●◗) — takes the theme color like everything else, just coarser.
  3. Nerd Fonts’ Weather Icons set — 28 phases, theme-colored, the real deal. I pulled the codepoints straight from ryanoasis/nerd-fontsglyphnames.json to make sure they were right. The catch: there’s no way for a CLI process to detect whether your terminal font is actually Nerd Font-patched. No API for that across terminals. So it’s opt-in only, same tradeoff Starship and Oh My Posh make for the same reason.

Monochrome is the default. Emoji and Nerd Font are there if you want them.

Why its own segment

I could’ve made today take a period option instead of adding a whole new segment. Didn’t, because that changes the config shape for everyone already using today. I also didn’t wire month into the old hardcoded TUI layout — that would’ve silently added a line to every existing TUI dashboard. It only shows up there if you’re already using the TUI grid mode, which is opt-in to begin with.

PR’s open: #112.