Created
March 23, 2026 16:50
-
-
Save kamilmodest/c0725fc68a8b28e6ac8c61d29e7ce25b to your computer and use it in GitHub Desktop.
Claude Code status line
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
Show hidden characters
| // ~/.claude/settings.json | |
| "statusLine": { | |
| "type": "command", | |
| "command": "bash /Users/k.babaev/.claude/statusline-command.sh" | |
| } |
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
| # ~/.claude/statusline-command.sh | |
| #!/usr/bin/env bash | |
| # Claude Code status line — inspired by the af-magic oh-my-zsh theme | |
| input=$(cat) | |
| cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd // empty') | |
| model=$(echo "$input" | jq -r '.model.display_name // empty') | |
| used=$(echo "$input" | jq -r '.context_window.used_percentage // empty') | |
| # Shorten path: replace $HOME with ~, then keep last 3 components for deep paths | |
| if [ -n "$cwd" ]; then | |
| home="$HOME" | |
| short_path="${cwd/#$home/\~}" | |
| # Count path components (split by /) | |
| depth=$(echo "$short_path" | tr -cd '/' | wc -c | tr -d ' ') | |
| if [ "$depth" -ge 4 ]; then | |
| parent=$(echo "$short_path" | rev | cut -d'/' -f1-3 | rev) | |
| first=$(echo "$short_path" | cut -d'/' -f1) | |
| short_path="${first}/…/${parent}" | |
| fi | |
| fi | |
| # Git branch (skip optional lock) | |
| git_branch="" | |
| if git -C "$cwd" rev-parse --git-dir --no-optional-locks >/dev/null 2>&1; then | |
| git_branch=$(git -C "$cwd" symbolic-ref --short HEAD 2>/dev/null || git -C "$cwd" rev-parse --short HEAD 2>/dev/null) | |
| fi | |
| # LiteLLM budget (cached for 60s) | |
| litellm_info="" | |
| cache_file="/tmp/.claude-litellm-cache" | |
| cache_ttl=60 | |
| now=$(date +%s) | |
| if [ -f "$cache_file" ]; then | |
| cache_age=$(( now - $(stat -f '%m' "$cache_file" 2>/dev/null || echo 0) )) | |
| else | |
| cache_age=$((cache_ttl + 1)) | |
| fi | |
| if [ "$cache_age" -gt "$cache_ttl" ]; then | |
| litellm_json=$(dp-devinfra litellm usage -o json 2>/dev/null) | |
| if [ -n "$litellm_json" ]; then | |
| echo "$litellm_json" > "$cache_file" | |
| fi | |
| else | |
| litellm_json=$(cat "$cache_file" 2>/dev/null) | |
| fi | |
| if [ -n "$litellm_json" ]; then | |
| spend=$(echo "$litellm_json" | jq -r '.spend // empty') | |
| budget=$(echo "$litellm_json" | jq -r '.totalBudget // empty') | |
| if [ -n "$spend" ] && [ -n "$budget" ]; then | |
| litellm_info="Usage: $(printf '%.1f' "$spend")/$(printf '%.0f' "$budget")" | |
| fi | |
| fi | |
| # Build output parts | |
| parts=() | |
| [ -n "$short_path" ] && parts+=("$short_path") | |
| [ -n "$git_branch" ] && parts+=("git:${git_branch}") | |
| [ -n "$model" ] && parts+=("${model}") | |
| [ -n "$used" ] && parts+=("ctx:$(printf '%.0f' "$used")%") | |
| [ -n "$litellm_info" ] && parts+=("$litellm_info") | |
| printf '%s' "$(printf '%s\n' "${parts[@]}" | paste -sd'·' - | sed 's/·/ · /g')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment