Skip to content

Instantly share code, notes, and snippets.

@msysyamamoto
Created April 27, 2026 12:08
Show Gist options
  • Select an option

  • Save msysyamamoto/954208888b0e568839e204abdab99f9b to your computer and use it in GitHub Desktop.

Select an option

Save msysyamamoto/954208888b0e568839e204abdab99f9b to your computer and use it in GitHub Desktop.
~/.claude/statusline-command.sh
#!/bin/bash
# 標準入力からJSON形式のデータを読み込む
input=$(cat)
# 各種情報を取得
model=$(echo "$input" | jq -r '.model.display_name // "Claude"')
used=$(echo "$input" | jq -r '.context_window.used_percentage // "0"')
total_in=$(echo "$input" | jq -r '.context_window.total_input_tokens // 0')
total_out=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')
max_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 0')
duration_ms=$(echo "$input" | jq -r '.cost.total_api_duration_ms // "0"')
five_hour=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // "N/A"')
seven_day=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // "N/A"')
# 使用済みトークンをk単位に変換
used_tokens=$(( total_in + total_out ))
used_k=$(echo "scale=0; $used_tokens / 1000" | bc)
max_k=$(echo "scale=0; $max_tokens / 1000" | bc)
# レイテンシを秒に変換(小数点1桁)
latency=$(echo "scale=1; $duration_ms / 1000" | bc)
# ステータスライン表示
echo "${model} | Context: ${used_k}k/${max_k}k (${used}%) | 5h: ${five_hour}% | 7d: ${seven_day}% | ${latency}s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment