DEV Community

Cover image for Building a Complete Developer Terminal Setup for Claude Code — Part 2: Custom Statusline
Avinash Seethalam
Avinash Seethalam

Posted on

Building a Complete Developer Terminal Setup for Claude Code — Part 2: Custom Statusline

Building a Complete Developer Terminal Setup for Claude Code — Part 2: Custom Statusline

By Avinash, GenAI Practice Lead | Part 1 | Part 2 of 6

⚠️ Note: This setup is macOS-specific. All tools, commands, and configurations in this series are tested on macOS (Apple Silicon). Linux and Windows users will need to adapt certain steps, particularly around afplay, brew, iTerm2, and system font installation.


Claude Code supports a statusLine configuration that pipes a live JSON object to a bash script on every update. Most developers ignore this. I spent time building it out properly and it's now the most-glanced piece of my development environment.

Here's what my statusline shows in a real session:

Claude Sonnet 4.6 [Pro] | ⎇ feature/docling-eval | in:42k out:8k | ctx 61% | $0.0284 | +142/-38 | 5h 31% ⏱ 3h12m | 7d 18% ⏱ 4d6h
Enter fullscreen mode Exit fullscreen mode

Each segment is deliberate. Let me walk through them.


What Each Segment Shows

Model nameClaude Sonnet 4.6 [Pro]. Useful when switching between Sonnet and Opus mid-project. You always know what you're paying for.

Git branch⎇ feature/docling-eval. The script uses workspace.current_dir from the JSON payload for accuracy in worktree setups, not the shell's current directory.

Token usagein:42k out:8k. Input and output tokens in compact k format. Abbreviated above 1000, raw below — so early in a session you see in:340 out:89 and it flips to in:1k naturally as it grows.

Context %ctx 61% with color thresholds tuned for Pro plan. Green below 50%, yellow at 50%, orange at 60%, red at 75%. These are tighter than defaults because on Pro every token in a compacted context gets re-billed.

Cost$0.0284 to 4 decimal places. Three decimal places rounds sub-cent sessions in a way that loses signal. At 4dp you can see the actual cost of a session clearly.

Lines changed+142/-38. Only appears when there are actual file edits. Stays clean during pure Q&A work.

5-hour rate limit5h 31% ⏱ 3h12m. Usage percentage and countdown to reset. On Pro this is what tells you whether to push through a task or wrap up cleanly.

7-day rate limit7d 18% ⏱ 4d6h. The weekly ceiling is the one that bites during multi-day project sprints. Knowing you're at 18% on Wednesday is actionable in a way that daily usage alone isn't.

Compaction warning — at 75% context the display shows a blinking ⚠ COMPACT. This fires earlier than the default because on Pro, hitting auto-compaction mid-task reruns your entire context through the API.


The Implementation

The script is pure bash with jq as the only dependency. jq is a command-line JSON parser — install it with brew install jq.

Wire it up in ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh"
  }
}
Enter fullscreen mode Exit fullscreen mode

The script reads from stdin (input=$(cat)), extracts fields with jq, applies color logic with ANSI escape codes, and outputs a single line. The JSON payload contains everything — model info, context window state, cost, rate limits, and workspace path.


Testing Without a Live Session

You don't need to start a Claude Code session to test the script. Pipe mock JSON directly:

echo '{"model":{"display_name":"Claude Sonnet 4.6"},"workspace":{"current_dir":"/your/project"},"context_window":{"total_input_tokens":12000,"total_output_tokens":3000,"used_percentage":45},"cost":{"total_cost_usd":0.0084,"total_lines_added":42,"total_lines_removed":7},"rate_limits":{"five_hour":{"used_percentage":38,"resets_at":'"$(( $(date +%s) + 7200 ))"'},"seven_day":{"used_percentage":22,"resets_at":'"$(( $(date +%s) + 345600 ))"'}}}' | ~/.claude/statusline.sh
Enter fullscreen mode Exit fullscreen mode

The reset timestamps are computed from now + seconds so the countdown shows real numbers.


One Tradeoff Worth Knowing

The used_percentage field is calculated from input tokens only — it does not include output tokens. So the context % reflects input-side pressure, which is the more meaningful signal for context window exhaustion, but it may differ slightly from what /context reports. The script displays raw input and output token counts separately precisely for this reason.


The full script is at https://github.com/ai-with-avinash/claude-code-best-setup.

Back to Part 1 | Continue to Part 3 → Sound Notification Hooks

Top comments (0)