Usage Bars
auditedFreeTwo full-width meters: context window usage and your plan 5-hour rate limit usage, color-coded green/amber/red as they fill. Pure bash string parsing, zero dependencies, no subprocesses, no network, no files.
by anonymous2 installscontextrate-limitbarsminimalno-deps
Claude Code
>
? for shortcuts⏵⏵ accept edits on
Security auditby claude-sonnet-4-5
Displays two progress bars showing Claude Code context window usage and 5-hour rate limit usage, color-coded green/amber/red. Reads session JSON from stdin, parses it with pure bash regex patterns to extract percentage values, then renders two formatted bars using ANSI escape codes and Unicode block characters. No subprocesses, no network, no file I/O.
reads-stdinenv-vars
Audits are advisory. This script runs on your machine — read it before installing.
2 installs
The script — read it before you run it
#!/usr/bin/env bash
# usage-bars — two full-width meters for the Claude Code status line:
# ctx how much of the context window is used
# plan how much of the plan's 5-hour rate limit is used
# Fill is color-coded: green under 50%, amber under 80%, red at 80%+.
# Pure bash string parsing of the statusline JSON. No jq, no subprocesses,
# no network, no files.
input=$(cat)
# UTF-8 locale so ${#var} counts characters, not bytes.
export LC_ALL=en_US.UTF-8
cols=${COLUMNS:-80}
# used_percentage that follows a given JSON key ("context_window",
# "five_hour"), or -1 when the field is absent.
pct_after() {
local part=${input#*\"$1\"}
if [[ $part == "$input" ]]; then echo -1; return; fi
if [[ $part =~ \"used_percentage\"[[:space:]]*:[[:space:]]*([0-9]+) ]]; then
echo "${BASH_REMATCH[1]}"
else
echo -1
fi
}
ctx=$(pct_after context_window)
plan=$(pct_after five_hour)
bar() { # $1 label · $2 percent (-1 = unknown)
local label=$1 pct=$2
# label(5) + bar + space + "100%"(4) + 6 columns of right margin — Claude
# Code adds its own padding around the status line and truncates anything
# that reaches the edge, which would eat the trailing percentage.
local width=$(( cols - 16 ))
(( width < 10 )) && width=10
if (( pct < 0 )); then
local pad; printf -v pad '%*s' "$width" ''; pad=${pad// /░}
printf '%-5s\033[2m%s\033[0m n/a' "$label" "$pad"
return
fi
(( pct > 100 )) && pct=100
local filled=$(( pct * width / 100 ))
local empty=$(( width - filled ))
local color='38;2;96;200;112' # green
(( pct >= 50 )) && color='38;2;220;180;70' # amber
(( pct >= 80 )) && color='38;2;225;95;85' # red
local fill='' pad=''
if (( filled > 0 )); then printf -v fill '%*s' "$filled" ''; fill=${fill// /▓}; fi
if (( empty > 0 )); then printf -v pad '%*s' "$empty" ''; pad=${pad// /░}; fi
printf '%-5s\033[%sm%s\033[0m\033[2m%s\033[0m %3d%%' \
"$label" "$color" "$fill" "$pad" "$pct"
}
printf '%s\n%s' "$(bar ctx "$ctx")" "$(bar plan "$plan")"