Last active
March 20, 2026 09:41
-
-
Save hugcis/c08ad06131ca0812b406e14f2f93ad2b to your computer and use it in GitHub Desktop.
Claude Code status line – git info, context bar, vim mode, API usage with pace tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input=$(cat) | |
| # Color constants (using $'...' so escape sequences are real) | |
| RST=$'\033[0m' | |
| DIM=$'\033[2m' | |
| RED=$'\033[31m' | |
| GRN=$'\033[32m' | |
| YLW=$'\033[33m' | |
| MAG=$'\033[35m' | |
| CYN=$'\033[36m' | |
| # Parse JSON — one value per line to handle empty fields correctly | |
| { | |
| read -r cwd | |
| read -r used_pct | |
| read -r vim_mode | |
| read -r five_pct | |
| read -r five_reset | |
| read -r seven_pct | |
| read -r seven_reset | |
| } < <(jq -r ' | |
| (.workspace.current_dir // .cwd), | |
| (.context_window.used_percentage // ""), | |
| (.vim.mode // ""), | |
| (.rate_limits.five_hour.used_percentage // ""), | |
| (.rate_limits.five_hour.resets_at // ""), | |
| (.rate_limits.seven_day.used_percentage // ""), | |
| (.rate_limits.seven_day.resets_at // "") | |
| ' <<< "$input") | |
| dir=$(basename "$cwd") | |
| # Helper: build a progress bar | |
| make_bar() { | |
| local val=$1 width=$2 fill_ch=$3 empty_ch=$4 | |
| local filled=$(( val * width / 100 )) | |
| [ $filled -gt $width ] && filled=$width | |
| [ $filled -lt 0 ] && filled=0 | |
| local empty=$(( width - filled )) | |
| local full="" blank="" | |
| printf -v full '%*s' "$filled" ''; full="${full// /$fill_ch}" | |
| printf -v blank '%*s' "$empty" ''; blank="${blank// /$empty_ch}" | |
| printf '%s' "${full}${blank}" | |
| } | |
| # Helper: threshold color | |
| threshold_color() { | |
| local val=$1 | |
| if [ "$val" -ge 80 ]; then printf '%s' "$RED" | |
| elif [ "$val" -ge 50 ]; then printf '%s' "$YLW" | |
| else printf '%s' "$GRN"; fi | |
| } | |
| # Git branch + clean/dirty | |
| git_info="" | |
| if git -C "$cwd" rev-parse --git-dir > /dev/null 2>&1; then | |
| status=$(git -C "$cwd" --no-optional-locks status --branch --porcelain 2>/dev/null) | |
| branch=$(head -1 <<< "$status" | sed 's/^## //;s/\.\.\..*//') | |
| if [ -n "$branch" ]; then | |
| if [ ${#branch} -gt 30 ]; then | |
| branch="${branch:0:27}..." | |
| fi | |
| if [ "$(wc -l <<< "$status")" -gt 1 ]; then si="●"; else si="✓"; fi | |
| git_info=" ${YLW}git:(${RST}${branch} ${si}${YLW})${RST}" | |
| fi | |
| fi | |
| # Context window bar | |
| ctx="" | |
| if [ -n "$used_pct" ]; then | |
| pct=$(printf '%.0f' "$used_pct") | |
| bar=$(make_bar "$pct" 20 "█" "░") | |
| ctx_color=$(threshold_color "$pct") | |
| suffix=""; [ "$pct" -ge 80 ] && suffix="!" | |
| ctx=" ${ctx_color}${bar} ${pct}%${suffix}${RST}" | |
| fi | |
| # Vim mode | |
| vim_info="" | |
| if [ -n "$vim_mode" ]; then | |
| if [ "$vim_mode" = "NORMAL" ]; then | |
| vim_info=" ${MAG}[N]${RST}" | |
| else | |
| vim_info=" ${MAG}[I]${RST}" | |
| fi | |
| fi | |
| # Rate limits | |
| usage_info="" | |
| if [ -n "$five_pct" ] && [ -n "$seven_pct" ]; then | |
| five_int=$(printf '%.0f' "$five_pct") | |
| seven_int=$(printf '%.0f' "$seven_pct") | |
| now_epoch=$(date +%s) | |
| # 5h reset countdown | |
| five_reset_label="" | |
| if [[ "$five_reset" =~ ^[0-9]+$ ]] && [ "$five_reset" -gt 0 ]; then | |
| if [ "$five_reset" -gt "$now_epoch" ]; then | |
| secs_left=$(( five_reset - now_epoch )) | |
| hrs=$(( secs_left / 3600 )) | |
| mins=$(( (secs_left % 3600) / 60 )) | |
| if [ "$hrs" -gt 0 ]; then | |
| five_reset_label="${hrs}h${mins}m" | |
| else | |
| five_reset_label="${mins}m" | |
| fi | |
| fi | |
| fi | |
| # Weekly pace | |
| pace_icon="" | |
| diff=0 | |
| if [[ "$seven_reset" =~ ^[0-9]+$ ]] && [ "$seven_reset" -gt 0 ]; then | |
| elapsed=$(( now_epoch - (seven_reset - 604800) )) | |
| time_pct=$(( elapsed * 100 / 604800 )) | |
| [ $time_pct -lt 0 ] && time_pct=0 | |
| [ $time_pct -gt 100 ] && time_pct=100 | |
| diff=$(( seven_int - time_pct )) | |
| if [ $diff -gt 10 ]; then pace_icon="▲" | |
| elif [ $diff -gt 5 ]; then pace_icon="△" | |
| elif [ $diff -lt -10 ]; then pace_icon="▽" | |
| elif [ $diff -lt -5 ]; then pace_icon="▿" | |
| fi | |
| fi | |
| # 5h bar + color | |
| five_bar=$(make_bar "$five_int" 5 "▮" "▯") | |
| five_color=$(threshold_color "$five_int") | |
| # Weekly bar + color | |
| wbar=$(make_bar "$seven_int" 10 "▮" "▯") | |
| wcolor=$(threshold_color "$seven_int") | |
| # Pace color | |
| if [ $diff -gt 5 ]; then pcolor="$RED" | |
| elif [ $diff -lt -5 ]; then pcolor="$CYN" | |
| else pcolor=""; fi | |
| # Build rate limit display | |
| five_section="${five_color}${five_bar} ${five_int}%${RST}" | |
| [ -n "$five_reset_label" ] && five_section="${five_section} ${DIM}${five_reset_label}${RST}" | |
| week_section="${wcolor}${wbar} ${seven_int}%${RST}" | |
| [ -n "$pace_icon" ] && week_section="${week_section}${pcolor}${pace_icon}${RST}" | |
| usage_info=" ${DIM}│${RST} 5h ${five_section} ${DIM}│${RST} 7d ${week_section}" | |
| fi | |
| printf '%s' "${CYN}${dir}${RST}${git_info}${ctx}${vim_info}${usage_info}" |
Author
hugcis
commented
Feb 24, 2026
Author
tqt-webapp git:(feature/heroku-provisioning... ●) ░░░░░░░░░░░░░░░░░░░░ 4% │ 5h ▯▯▯▯▯ 6% 3h19m │ 7d ▮▮▮▯▯▯▯▯▯▯ 35%▽
⏵⏵ accept edits on (shift+tab to cycle) · PR #3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment