Last active
April 21, 2026 13:41
-
-
Save kuzdogan/7f8828caa3a992437d9a5eb886d206b5 to your computer and use it in GitHub Desktop.
Claude Code allows custom status lines. I created a nice one with this. Tell your Claude to read this https://code.claude.com/docs/en/statusline and implement it
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/sh | |
| # Claude Code allows custom status lines. I created a nice one with this. Tell your Claude to read this https://code.claude.com/docs/en/statusline and implement it | |
| # Claude Code status line — mirrors Powerlevel10k prompt elements: | |
| # dir | git branch+status | node version | model | context usage | |
| input=$(cat) | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| model=$(echo "$input" | jq -r '.model.display_name // empty') | |
| used_pct=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| ctx_size=$(echo "$input" | jq -r '.context_window.context_window_size // empty') | |
| cost=$(echo "$input" | jq -r '.cost.total_cost_usd // empty') | |
| rate_5h=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty') | |
| rate_7d=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty') | |
| rate_5h_resets=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty') | |
| rate_7d_resets=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty') | |
| # used_tokens = input + cache_creation + cache_read (same formula as used_percentage, excludes output) | |
| used_tokens=$(echo "$input" | jq -r ' | |
| if .context_window.current_usage != null then | |
| ((.context_window.current_usage.input_tokens // 0) | |
| + (.context_window.current_usage.cache_creation_input_tokens // 0) | |
| + (.context_window.current_usage.cache_read_input_tokens // 0)) | |
| else empty end') | |
| # Shorten the directory (replace $HOME with ~) | |
| home="$HOME" | |
| short_dir="${cwd/#$home/\~}" | |
| # Git branch and status (skip optional locks for safety) | |
| git_info="" | |
| if git -C "$cwd" rev-parse --git-dir >/dev/null 2>&1; then | |
| branch=$(git -C "$cwd" symbolic-ref --short HEAD 2>/dev/null \ | |
| || git -C "$cwd" rev-parse --short HEAD 2>/dev/null) | |
| if [ -n "$branch" ]; then | |
| # Check for uncommitted changes | |
| if git -C "$cwd" status --porcelain --no-lock-index 2>/dev/null | grep -q .; then | |
| git_info=" ($branch *)" | |
| else | |
| git_info=" ($branch)" | |
| fi | |
| fi | |
| fi | |
| # Node version via nvm (best-effort) | |
| node_info="" | |
| if command -v node >/dev/null 2>&1; then | |
| node_ver=$(node --version 2>/dev/null) | |
| [ -n "$node_ver" ] && node_info=" node:$node_ver" | |
| fi | |
| # Context usage | |
| ctx_info="" | |
| if [ -n "$used_pct" ]; then | |
| pct="$(printf '%.0f' "$used_pct")%" | |
| if [ -n "$used_tokens" ]; then | |
| # Format token count with k suffix if >= 1000 | |
| if [ "$used_tokens" -ge 1000 ] 2>/dev/null; then | |
| tok="$(printf '%.1fk' "$(echo "$used_tokens" | awk '{printf "%.1f", $1/1000}')")" | |
| else | |
| tok="${used_tokens}" | |
| fi | |
| ctx_info="${pct} context (${tok} tokens)" | |
| else | |
| ctx_info="${pct} context" | |
| fi | |
| fi | |
| # Cost | |
| cost_info="" | |
| if [ -n "$cost" ]; then | |
| cost_info="\$$(printf '%.4f' "$cost")" | |
| fi | |
| # Format seconds into Xd Yh, Xh Ym, or Xm | |
| fmt_remaining() { | |
| secs="$1" | |
| if [ "$secs" -le 0 ] 2>/dev/null; then | |
| echo "now" | |
| elif [ "$secs" -ge 86400 ]; then | |
| echo "$(( secs / 86400 ))d $(( (secs % 86400) / 3600 ))h" | |
| elif [ "$secs" -ge 3600 ]; then | |
| echo "$(( secs / 3600 ))h $(( (secs % 3600) / 60 ))m" | |
| else | |
| echo "$(( secs / 60 ))m" | |
| fi | |
| } | |
| # Rate limits | |
| rate_info="" | |
| if [ -n "$rate_5h" ] || [ -n "$rate_7d" ]; then | |
| now=$(date +%s) | |
| r5="$(printf '%.0f' "${rate_5h:-0}")%" | |
| r7="$(printf '%.0f' "${rate_7d:-0}")%" | |
| if [ -n "$rate_5h_resets" ]; then | |
| r5="${r5} (resets in $(fmt_remaining $(( rate_5h_resets - now )) ))" | |
| fi | |
| if [ -n "$rate_7d_resets" ]; then | |
| r7="${r7} (resets in $(fmt_remaining $(( rate_7d_resets - now )) ))" | |
| fi | |
| rate_info="5h:${r5} 7d:${r7}" | |
| fi | |
| # Model info | |
| model_info="" | |
| [ -n "$model" ] && model_info="[$model]" | |
| # Folder name only | |
| folder="${cwd##*/}" | |
| # Build output with | separators, model first | |
| out="" | |
| [ -n "$model_info" ] && out="$model_info" | |
| [ -n "$folder" ] && out="$out | 📁 $folder" | |
| [ -n "$git_info" ] && out="$out |$git_info" | |
| [ -n "$node_info" ] && out="$out |$node_info" | |
| [ -n "$ctx_info" ] && out="$out | $ctx_info" | |
| [ -n "$cost_info" ] && out="$out | $cost_info" | |
| [ -n "$rate_info" ] && out="$out | $rate_info" | |
| # Strip leading " | " if model was empty | |
| out="${out# | }" | |
| printf "%s" "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment