# #11: Custom Status Lines 📊

> Customizing the bar at the bottom of Claude Code with a status line. A status line is a shell command that Claude Code runs for us.

Published 2026-11-09 by Jake Marsh on Little Cups of Claude. Canonical: https://littlecupsofclaude.com/11
Topics: [Claude Code CLI](https://littlecupsofclaude.com/topics/claude-code-cli), [Tips](https://littlecupsofclaude.com/topics/tips)

Today we'll look at customizing the bar at the bottom of **Claude Code** with a **status line**.

A **status line** is a shell command that **Claude Code** runs for us. It receives session data as **JSON** on stdin, and whatever it prints shows up in its own row above the built-in footer. It runs locally, so it doesn't use any API tokens.

Let's dive in.

## Let Claude Write It

The quickest way to get one is to describe what we want with the `/statusline` command:

```text
/statusline show model name and context percentage with a progress bar
```

**Claude Code** writes a script into `~/.claude/` and updates our settings for us. To get rid of it later, `/statusline clear` (or `/statusline delete`) removes it.

## The Setting

Under the hood, it's just a `statusLine` entry in `~/.claude/settings.json` or our project settings:

```json
{
  "statusLine": {
    "type": "command",
    "command": "~/.claude/statusline.sh",
    "padding": 2,
    "refreshInterval": 5
  }
}
```

`type` is always `"command"`, and `command` can be a script path or an inline shell command. `padding` adds a little horizontal spacing. `refreshInterval` re-runs the command every N seconds, which is handy for clocks or anything that changes while the session sits idle. Without it, the script only runs on events, like a new assistant message, `/compact` finishing, or a permission mode change.

## Writing Our Own

Here's a small script that shows the model, the folder we're in, and how full the context window is:

```bash
#!/bin/bash
input=$(cat)

MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)

echo "[$MODEL] ${DIR##*/} | ${PCT}% context"
```

We make it executable and we're done. **Claude Code** reloads settings automatically, so the bar shows up as soon as we save:

```bash
chmod +x ~/.claude/statusline.sh
```

Every `echo` becomes its own row, so multi-line status lines work too. ANSI color codes like `\033[32m` work as well.

## Fields Worth Knowing

The **JSON** has quite a bit in it. A few favorites:

- `cost.total_cost_usd` and `cost.total_duration_ms` for an estimated session cost and running time
- `context_window.used_percentage` and `context_window.context_window_size`
- `rate_limits.five_hour.used_percentage` for Pro, Max, and Ultra subscribers
- `session_name`, `effort.level`, and `pr.number`
- `worktree.name` and `worktree.branch` while we're in a worktree session

Here's a cost and time readout:

```bash
#!/bin/bash
input=$(cat)

COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
SECS=$((MS / 1000))

printf '$%.2f | %dm %ds\n' "$COST" $((SECS / 60)) $((SECS % 60))
```

Some fields are absent or `null` depending on the session. `rate_limits` only appears after the first API response, and `vim` only appears with vim mode on. The `// 0` and `// empty` fallbacks in `jq` keep things from breaking.

## Testing And Gotchas

We don't need a live session to try a script. We can pipe in some mock **JSON** ourselves:

```bash
echo '{"model":{"display_name":"Hal"},"workspace":{"current_dir":"/home/dave/discovery"},"context_window":{"used_percentage":25}}' \
  | ~/.claude/statusline.sh
```

Neat! A few things to watch for:

- The output only shows when the script exits with code `0`. An error or empty output leaves the bar blank.
- The script runs often, so slow commands like `git status` can lag. The docs suggest caching results in a file keyed by `session_id`.
- `tput cols` can't see the terminal from inside the script. We read the `COLUMNS` environment variable instead.
- Until we accept the workspace trust dialog for a folder, the status line stays blank.

More info about **status lines** can be found at [the Claude Code docs](https://code.claude.com/docs/en/statusline).
