Skip to content

Instantly share code, notes, and snippets.

@vladstudio
Created January 15, 2026 16:14
Show Gist options
  • Select an option

  • Save vladstudio/47413b30ba0caa32c8de4b58d255e00a to your computer and use it in GitHub Desktop.

Select an option

Save vladstudio/47413b30ba0caa32c8de4b58d255e00a to your computer and use it in GitHub Desktop.
Claude Code custom status line script - shows directory, git branch, diff stats, model, session duration, and context window usage
#!/bin/bash
# Claude Code statusline - single line with key info
input=$(cat)
# Extract data from JSON
dir=$(jq -r '.workspace.current_dir' <<< "$input")
dir_name=$(basename "$dir")
model=$(jq -r '.model.display_name // .model.id' <<< "$input")
duration_ms=$(jq -r '.cost.total_duration_ms // 0' <<< "$input")
# Git info
lines_added=0 lines_removed=0 branch=''
if cd "$dir" 2>/dev/null; then
branch=$(git -c core.useBuiltinFSMonitor=false branch --show-current 2>/dev/null)
diff_stats=$(git -c core.useBuiltinFSMonitor=false diff --shortstat 2>/dev/null)
[[ -n "$diff_stats" ]] && {
lines_added=$(sed -n 's/.* \([0-9]*\) insertion.*/\1/p' <<< "$diff_stats")
lines_removed=$(sed -n 's/.* \([0-9]*\) deletion.*/\1/p' <<< "$diff_stats")
: "${lines_added:=0}" "${lines_removed:=0}"
}
fi
# Context window usage
ctx='' ctx_color=''
usage=$(jq '.context_window.current_usage' <<< "$input")
if [[ "$usage" != "null" ]]; then
current=$(jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens' <<< "$usage")
size=$(jq '.context_window.context_window_size' <<< "$input")
used=$((current * 100 / size))
ctx="${used}%"
if ((used < 50)); then ctx_color='\033[92m'
elif ((used < 80)); then ctx_color='\033[93m'
else ctx_color='\033[91m'; fi
fi
# Format session time
session_time=''
if [[ "$duration_ms" != "0" && "$duration_ms" != "null" ]]; then
total_sec=$((duration_ms / 1000))
((h=total_sec/3600, m=total_sec%3600/60, s=total_sec%60))
((h > 0)) && session_time="${h}h ${m}m" || { ((m > 0)) && session_time="${m}m ${s}s" || session_time="${s}s"; }
fi
# Build status line
sep='\033[2m·\033[0m'
line=$(printf '\033[94m/%s\033[0m' "$dir_name")
[[ -n "$branch" ]] && line+=" $(printf "$sep"' \033[96m%s\033[0m' "$branch")"
[[ "$lines_added$lines_removed" != "00" ]] && line+=" $(printf "$sep"' \033[92m+%s\033[0m\033[91m-%s\033[0m' "$lines_added" "$lines_removed")"
line+=" $(printf "$sep"' \033[37m%s\033[0m' "$model")"
[[ -n "$session_time" ]] && line+=" $(printf "$sep"' \033[33m%s\033[0m' "$session_time")"
[[ -n "$ctx" ]] && line+=" $(printf "$sep"' %b%s\033[0m' "$ctx_color" "$ctx")"
printf '%b' "$line"
@vladstudio
Copy link
Author

image

@vladstudio
Copy link
Author

vladstudio commented Jan 15, 2026


# Download the script
  curl -o ~/.claude/statusline-command.sh https://gist.githubusercontent.com/vladstudio/47413b30ba0caa32c8de4b58d255e00a/raw/statusline-command.sh

  # Make it executable
  chmod +x ~/.claude/statusline-command.sh

  Configure (add to ~/.claude/settings.json):

"statusLine": {
  "type": "command",
  "command": "~/.claude/statusline-command.sh",
  "padding": 0
}

Requires: jq (install with brew install jq on macOS)

Shows: directory · git branch · +added/-removed lines · model · session time · context usage %

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment