dotfiles/claude/statusline-command.sh
mwiegand 8d5406b7ef
add Claude Code statusline script
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 22:59:51 +02:00

33 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
input=$(cat)
cwd=$(echo "$input" | jq -r '.workspace.current_dir // .cwd')
dir=$(basename "$cwd")
model=$(echo "$input" | jq -r '.model.display_name // ""')
# Git branch (skip optional locks)
branch=$(git -C "$cwd" symbolic-ref --quiet --short HEAD 2>/dev/null)
# Context usage
used=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
# Rate limits
rl_5h=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
rl_7d=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
# Thinking / effort
thinking=$(echo "$input" | jq -r '.thinking.enabled // empty')
effort=$(echo "$input" | jq -r '.effort.level // empty')
# Build dim suffix
dim=""
[[ -n "$branch" ]] && dim="$dim ($branch)"
[[ -n "$model" ]] && dim="$dim $model"
[[ -n "$effort" ]] && dim="$dim $effort"
[[ -n "$used" ]] && dim="$dim $(printf '%.0f%%' "$used")"
usage=""
[[ -n "$rl_5h" ]] && usage="$usage $(printf '%.0f%%/5h' "$rl_5h")"
[[ -n "$rl_7d" ]] && usage="$usage $(printf '%.0f%%/7d' "$rl_7d")"
[[ -n "$usage" ]] && dim="$dim -$usage"
printf '\033[1m%s\033[0m\033[2m%s\033[0m\n' "$dir" "$dim"