Created
March 31, 2026 13:16
-
-
Save wesort/550d8c1959517cd0982866b3ce61656b to your computer and use it in GitHub Desktop.
Claude Code statusline
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 Code Status Line Setup | |
| Configure a custom status line that runs a shell script (~/.claude/statusline-command.sh) and displays these pipe-separated segments: | |
| 1. Current working directory — read from the JSON stdin field workspace.current_dir (fallback to cwd) | |
| 2. Git branch — detect via git -C "$cwd" with --no-optional-locks. Color it red if on main, green otherwise. Append * if there are uncommitted staged or | |
| unstaged changes. | |
| 3. Model name — the display name of the active model from the JSON stdin | |
| 4. Context usage % — context window usage as a rounded integer (e.g., ctx 42%). Only show after at least one API call. | |
| 5. Session elapsed time — track session start time in /tmp/claude_session_start_<session_id> so it persists across refreshes. Format as Xs, Xm Ys, or Xh | |
| Ym depending on duration. | |
| Example output: | |
| /home/user/project | branch: dev | Claude Sonnet 4.6 | ctx 18% | 4m 32s | |
| Use ANSI escape codes for the branch colors and printf "%b\n" to render them. Set statusLine.type: "command" and statusLine.command: "bash | |
| ~/.claude/statusline-command.sh" in ~/.claude/settings.json. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment