From ba54cbf84e386c7028f49a618461df5c2c2da654 Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Thu, 11 Jun 2026 11:09:36 +0900 Subject: [PATCH] Compact unicode bars and reset time for rate limit segment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces ASCII [====] bars with █░ unicode blocks at width 8 (no brackets) for both context and rate limit segments. Replaces static "5h" label with actual reset time formatted as HH:MM. Co-Authored-By: Claude Sonnet 4.6 --- custom_statusline.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/custom_statusline.js b/custom_statusline.js index b971c2d..663cc69 100644 --- a/custom_statusline.js +++ b/custom_statusline.js @@ -74,20 +74,19 @@ process.stdin.on('end', () => { (data.model && data.model.id) || 'Claude'; + // --- Bar helper --- + const BAR_WIDTH = 8; + function makeBar(pct, color) { + const filled = Math.round((pct / 100) * BAR_WIDTH); + return `${color}` + '█'.repeat(filled) + `${DIM}` + '░'.repeat(BAR_WIDTH - filled) + `${color} ${pct}%${R}`; + } + // --- Context window usage --- const pct = Math.round( (data.context_window && data.context_window.used_percentage) || 0 ); - const barColor = pct >= 90 ? BAR_CRIT : pct >= 70 ? BAR_WARN : BAR_OK; - - const BAR_WIDTH = 10; - const filled = Math.round((pct / 100) * BAR_WIDTH); - const bar = - `${barColor}[` + - '='.repeat(filled) + - `${DIM}` + ' '.repeat(BAR_WIDTH - filled) + - `${barColor}] ${pct}%${R}`; + const bar = makeBar(pct, barColor); // --- 5h rate limit + cost --- const fiveHour = data.rate_limits && data.rate_limits.five_hour; @@ -99,13 +98,10 @@ process.stdin.on('end', () => { if (fiveHour) { const fivePct = Math.round(fiveHour.used_percentage); const fiveColor = fivePct >= 90 ? BAR_CRIT : fivePct >= 70 ? BAR_WARN : BAR_OK; - const fiveFilled = Math.round((fivePct / 100) * BAR_WIDTH); - const fiveBar = - `${fiveColor}[` + - '='.repeat(fiveFilled) + - `${DIM}` + ' '.repeat(BAR_WIDTH - fiveFilled) + - `${fiveColor}] ${fivePct}%${R}`; - parts.push(`5h ${fiveBar}`); + const resetDate = new Date(fiveHour.resets_at * 1000); + const hh = String(resetDate.getHours()).padStart(2, '0'); + const mm = String(resetDate.getMinutes()).padStart(2, '0'); + parts.push(`${hh}:${mm} ${makeBar(fivePct, fiveColor)}`); } if (totalCost) { parts.push(`${DIM}$${totalCost.toFixed(2)}${R}`);