An open API service indexing awesome lists of open source software.

https://github.com/momenbasel/claude-code-statusline


https://github.com/momenbasel/claude-code-statusline

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

          

# Claude Code Statusline

A single-line [Claude Code](https://docs.anthropic.com/en/docs/claude-code) statusline:
agnoster-style powerline segments, per-account identity, a Pac-Man context-window
muncher, and a live rate-limit gauge. Pure `bash` + `jq`, no dependencies to build.

```
you MAX 20× ✦ Opus 4.8 ~/projects/acme-api main *3 ↑1 ᗧ········•••••• 42% 84k/200k 5h 65% · 7d 88%
└ account └ plan └ model └ path └ git └ context gauge └ usage limits
```

Each `` is a powerline separator and each leading icon is a Nerd Font glyph — the
line above is the plain-text skeleton; on a real terminal with a Nerd Font it renders
as solid colored segments with arrows and icons.

## Features

- **Powerline segments** — account · org · plan · model · path · git · context · limits, each on its own colored block with agnoster arrows.
- **Per-account identity** — reads the *active* account from `~/.claude.json` (respects `CLAUDE_CONFIG_DIR`), so the badge follows whichever account/org/plan you're logged into. Team/Enterprise orgs get an org badge; personal accounts stay clean.
- **Pac-Man context muncher** — the gauge eats food dots as the context window fills; turns green → amber → red under pressure, with a blinking ghost. Animates while Claude is working (needs `gdate`).
- **Live rate-limit gauge** — 5-hour and 7-day remaining %, color-coded, straight from the payload Claude Code sends.
- **Git segment** — branch, dirty count `*N`, ahead `↑N` / behind `↓N` vs upstream.
- **Two styles** — `powerline` (Nerd Font) or `plain` (no special glyphs, works in any font).
- **ASCII-safe source** — all glyphs are built with `printf '\xNN'`, so the script survives copy/paste, gists, and git without losing its icons.

## Requirements

- `bash` and [`jq`](https://jqlang.github.io/jq/) (`brew install jq`)
- A **Nerd Font** for the `powerline` style — install one from [nerdfonts.com](https://www.nerdfonts.com) and select it in your terminal. (Or set `STYLE=plain` and skip this.)
- *Optional:* `coreutils` for `gdate` (`brew install coreutils`) — enables the smooth muncher animation. Without it the bar still works, just doesn't animate.

## Install

```bash
git clone https://github.com/momenbasel/claude-code-statusline.git
cd claude-code-statusline
./install.sh
```

`install.sh` copies `statusline.sh` to `~/.claude/scripts/` and sets `.statusLine` in
`~/.claude/settings.json` (backing up the old file first). Open a new Claude Code
session and it appears.

**Manual install** — copy `statusline.sh` anywhere and point Claude Code at it:

```jsonc
// ~/.claude/settings.json
{
"statusLine": { "type": "command", "command": "~/.claude/scripts/statusline.sh" }
}
```

## Preview

See it without launching Claude Code (renders at several fill levels):

```bash
./demo.sh
```

## Configuration

Toggles live at the top of `statusline.sh`:

| Variable | Default | What it does |
|-----------------|--------------|---------------------------------------------------------------------|
| `STYLE` | `powerline` | `powerline` (Nerd Font) or `plain` (no special glyphs) |
| `GAUGE` | `pacman` | `pacman` muncher or a `bar` (▰▱) meter |
| `GAUGE_W` | `20` | gauge width in cells — wider = finer resolution / more food dots |
| `ANIM` | `1` | animate the muncher while Claude re-renders (needs `gdate`) |
| `LOGOS` | `1` | show org / plan / folder icons |
| `SHOW_ACCOUNT` | `1` | show the account + org + plan badge |
| `SHOW_LIMITS` | `1` | show 5h + 7d usage remaining |
| `SHOW_LAST_MSG` | `0` | echo your last prompt on a second line |
| `ACCOUNT` | `""` | override the account name (empty = auto-detect) |
| `ORG_OVERRIDE` | `""` | override the org badge (empty = auto-detect) |
| `FRAME_MS` | `180` | muncher chomp period in ms |
| `BAR_DEBUG` | `0` | tee the stdin payload to `/tmp/cc-bar-input.json` for debugging |

### Custom glyph for a specific org

The org badge is data-driven — any org auto-detected from `~/.claude.json` gets a
generic building glyph plus its name. To give one org a custom icon, add a `case`
in the `LOGOS` block (search for `olog=`):

```bash
case "$org" in
ACME) olog=$(printf '\xee\x9c\xa2') ;; # any Nerd Font codepoint, as UTF-8 hex
esac
```

## Troubleshooting

- **Boxes / blank squares instead of icons** → your terminal font isn't a Nerd Font. Install one and select it, or set `STYLE=plain`.
- **No 5h / 7d limits** → your Claude Code build doesn't send `rate_limits` in the payload; the segment hides itself automatically.
- **Muncher doesn't animate** → install `coreutils` for `gdate` (`brew install coreutils`). Animation also only advances while Claude is actively re-rendering.
- **Wrong account shown** → the bar follows the active account in `$CLAUDE_CONFIG_DIR/.claude.json` (falling back to `~/.claude.json`). Set `ACCOUNT`/`ORG_OVERRIDE` to pin them.

## How it works

Claude Code pipes a JSON payload to the statusline command on stdin (model, cwd,
context window usage, rate limits, transcript path). The script parses it in a single
`jq` pass and renders one ANSI line. Context % comes from the payload when present, or
is reconstructed from the transcript tail as a fallback.

## License

MIT — see [LICENSE](LICENSE).