Compact unicode bars and reset time for rate limit segment

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 11:09:36 +09:00
parent 95af855cf5
commit ba54cbf84e
+12 -16
View File
@@ -74,20 +74,19 @@ process.stdin.on('end', () => {
(data.model && data.model.id) || (data.model && data.model.id) ||
'Claude'; '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 --- // --- Context window usage ---
const pct = Math.round( const pct = Math.round(
(data.context_window && data.context_window.used_percentage) || 0 (data.context_window && data.context_window.used_percentage) || 0
); );
const barColor = pct >= 90 ? BAR_CRIT : pct >= 70 ? BAR_WARN : BAR_OK; const barColor = pct >= 90 ? BAR_CRIT : pct >= 70 ? BAR_WARN : BAR_OK;
const bar = makeBar(pct, barColor);
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}`;
// --- 5h rate limit + cost --- // --- 5h rate limit + cost ---
const fiveHour = data.rate_limits && data.rate_limits.five_hour; const fiveHour = data.rate_limits && data.rate_limits.five_hour;
@@ -99,13 +98,10 @@ process.stdin.on('end', () => {
if (fiveHour) { if (fiveHour) {
const fivePct = Math.round(fiveHour.used_percentage); const fivePct = Math.round(fiveHour.used_percentage);
const fiveColor = fivePct >= 90 ? BAR_CRIT : fivePct >= 70 ? BAR_WARN : BAR_OK; const fiveColor = fivePct >= 90 ? BAR_CRIT : fivePct >= 70 ? BAR_WARN : BAR_OK;
const fiveFilled = Math.round((fivePct / 100) * BAR_WIDTH); const resetDate = new Date(fiveHour.resets_at * 1000);
const fiveBar = const hh = String(resetDate.getHours()).padStart(2, '0');
`${fiveColor}[` + const mm = String(resetDate.getMinutes()).padStart(2, '0');
'='.repeat(fiveFilled) + parts.push(`${hh}:${mm} ${makeBar(fivePct, fiveColor)}`);
`${DIM}` + ' '.repeat(BAR_WIDTH - fiveFilled) +
`${fiveColor}] ${fivePct}%${R}`;
parts.push(`5h ${fiveBar}`);
} }
if (totalCost) { if (totalCost) {
parts.push(`${DIM}$${totalCost.toFixed(2)}${R}`); parts.push(`${DIM}$${totalCost.toFixed(2)}${R}`);