cd /news/ai-tools/claude-code-status-line Β· home β€Ί topics β€Ί ai-tools β€Ί article
[ARTICLE Β· art-175269] src=gist.github.com β†— pub= topic=ai-tools verified=true sentiment=↑ positive

Claude Code status line

A developer published a bash script that renders a custom Claude Code status line, parsing the tool's JSON session data with a single jq pass to display the current folder, git branch, model and effort level, a context-window usage bar, remaining 5-hour and 7-day rate limits, and a reset countdown. The script extracts numeric fields first so newlines in text values cannot corrupt the bash arithmetic, applies green/yellow/red coloring at 70% and 90% usage, and only shows the 7-day limit once half of it is consumed.

recommendation

When building a Claude Code status line, emit numeric fields first from a single jq pass and default them with ': ${var:=...}' so malformed or non-JSON input can't break the arithmetic.

more in playbook: Working with AI coding agents
by read3 min views4 publishedNov 12, 2026

| | #!/usr/bin/env bash | | | # Claude Code status line: folder | branch | model Β· effort | context bar | 5-hour limit left | reset countdown | 7-day limit left (from 50% used) | | | | | | # One jq pass: the numbers on the first line ("-" when absent), then text values one per line, the path last, | | | # so a newline in any text value can't shift the numbers that reach bash arithmetic |

|  | { read -r pct rate_used reset_secs week_used; IFS= read -r model; IFS= read -r effort; IFS= read -r full_dir; } < <(jq -r ' | 
|  | def whole: if . then floor else "-" end; | 

| | .rate_limits as $r | | | | "(.context_window.used_percentage // 0 | floor) ($r.five_hour.used_percentage | whole) ($r.five_hour.resets_at | if . then floor - (now | floor) else "-" end) ($r.seven_day.used_percentage | whole)", |

|  | (.model.display_name // ""), | 
|  | (.effort \| if type == "object" then .level else . end // ""), | 

| | (.workspace.current_dir // .cwd // "") | | | ' 2>/dev/null) | | | # Defaults for when jq printed nothing (input that isn't JSON) | | | : "${pct:=0}" "${rate_used:=-}" "${reset_secs:=-}" "${week_used:=-}" "${full_dir:=$PWD}" | | | | | | RED=$'\033[31m'; YELLOW=$'\033[33m'; GREEN=$'\033[32m'; RESET=$'\033[0m' | | | # Colour for a percentage used: red from 90, yellow from 70 |

|  | colour() { | 
|  | if (( $1 >= 90 )); then printf '%s' "$RED" | 
|  | elif (( $1 >= 70 )); then printf '%s' "$YELLOW" | 

| | else printf '%s' "$GREEN"; fi | | | } | | | # "<label> N% left", coloured by the percentage used | | | left() { printf '%s%s %s%% left%s' "$(colour "$2")" "$1" $(( 100 - $2 )) "$RESET"; } | | | | | | # Folder: last two path components |

|  | parent=${full_dir%/*} | 
|  | parts=("πŸ“ ${parent##*/}/${full_dir##*/}") | 

| | | | | # Git branch (not in the JSON); empty when HEAD is detached |

|  | branch=$(git -C "$full_dir" branch --show-current 2>/dev/null) | 
|  | [[ -n "$branch" ]] && parts+=("βŽ‡ $branch") | 

| | | | | # Model, with the effort level when the model supports one | | | [[ -n "$model" ]] && parts+=("πŸ€– $model${effort:+ Β· $effort}") | | | | | | # Context window bar |

|  | filled=$(( pct / 10 )) | 
|  | printf -v bar_fill '%*s' "$filled" ''; printf -v bar_pad '%*s' $(( 10 - filled )) '' | 
|  | parts+=("$(colour "$pct")${bar_fill// /β–ˆ}${bar_pad// /β–‘}${RESET} ${pct}%") | 

| | | | | # 5-hour rate limit remaining and its reset countdown |

|  | [[ $rate_used != - ]] && parts+=("$(left 5h "$rate_used")") | 
|  | if [[ $reset_secs != - ]]; then | 
|  | if (( reset_secs <= 0 )); then parts+=("β†Ί now") | 
|  | elif (( reset_secs >= 3600 )); then parts+=("β†Ί $(( reset_secs / 3600 ))h$(( reset_secs % 3600 / 60 ))m") | 
|  | else parts+=("β†Ί $(( reset_secs / 60 ))m"); fi | 

| | fi | | | | | | # 7-day rate limit remaining, only once half of it is used | | | [[ $week_used != - ]] && (( week_used >= 50 )) && parts+=("$(left 7d "$week_used")") | | | |

|  | out=$(printf '%s  \|  ' "${parts[@]}") | 
|  | printf '%s\n' "${out%  \|  }" |
── more in #ai-tools 4 stories Β· sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/claude-code-status-l…] indexed:0 read:3min 2026-11-12 Β· β€”