OmniscioGuidesStatus line examplesA fast git row
A Claude Code status line that stays fast
This is Anthropic's caching example, printed here with the status line settings entry plus an optional refreshInterval. It answers the complaint the uncached git row creates: a script that runs four git commands on every update is fine in a small repository and a visible stall in a large one. Under the script is why the cache name matters, the one line that behaves differently on Linux and macOS, and how to prove the cache is doing its job.
Checked on November 26, 2026 against the Claude Code 2.1.332 documentation. By the Omniscio team. Updated .
What it shows
The same row as the git status example: model, folder, branch, a count of staged files and a count of modified files.
[Opus] ๐ my-app | ๐ฟ feature/login +2 ~3The difference is what happens behind it. The documented example caches git information to a temp file and only refreshes it every five seconds, so most redraws read one small file instead of running git four times.
That matters because a slow script blocks the row from updating until it finishes, and a new update arriving while it runs cancels it rather than waiting. In a large repository, uncached git calls can leave the row visibly behind the session.
The full script
Save this as ~/.claude/statusline.sh. It is Anthropic's cache example, printed here.
#!/bin/bash
input=$(cat)
MODEL=$(echo "$input" | jq -r '.model.display_name')
DIR=$(echo "$input" | jq -r '.workspace.current_dir')
SESSION_ID=$(echo "$input" | jq -r '.session_id')
CACHE_FILE="/tmp/statusline-git-cache-$SESSION_ID"
CACHE_MAX_AGE=5
cache_is_stale() {
[ ! -f "$CACHE_FILE" ] || \
[ $(($(date +%s) - $(stat -c %Y "$CACHE_FILE" 2>/dev/null || stat -f %m "$CACHE_FILE" 2>/dev/null || echo 0))) -gt $CACHE_MAX_AGE ]
}
if cache_is_stale; then
if git rev-parse --git-dir > /dev/null 2>&1; then
BRANCH=$(git branch --show-current 2>/dev/null)
STAGED=$(git diff --cached --numstat 2>/dev/null | wc -l | tr -d ' ')
MODIFIED=$(git diff --numstat 2>/dev/null | wc -l | tr -d ' ')
echo "$BRANCH|$STAGED|$MODIFIED" > "$CACHE_FILE"
else
echo "||" > "$CACHE_FILE"
fi
fi
IFS='|' read -r BRANCH STAGED MODIFIED < "$CACHE_FILE"
if [ -n "$BRANCH" ]; then
echo "[$MODEL] ๐ ${DIR##*/} | ๐ฟ $BRANCH +$STAGED ~$MODIFIED"
else
echo "[$MODEL] ๐ ${DIR##*/}"
fiThen make it executable, because the command runs in a shell:
chmod +x ~/.claude/statusline.shThe jq parser is a separate download from jqlang.org; check with jq --version before you blame the row on the cache.
Why the cache file is named after the session
The filename has two jobs at once: stay the same across every invocation within a session, and differ between sessions. If it is not stable, every run misses the cache; if it is not unique, two sessions running in different repositories read each other's branch and file counts.
Process identifiers look tempting and fail the first job. A shell's $$, Python's os.getpid() and Node's process.pid are new on every invocation, so the file is a different file every time and the cache never hits. The session_id from the JSON is stable for the life of the session and unique per session, which is exactly what the name needs.
CACHE_FILE="/tmp/statusline-git-cache-$SESSION_ID"With the name right, the script's first test is simple: the cache is stale when the file is missing, or when it is more than five seconds old. Only then does the git block run and rewrite it.
The one line that behaves differently on Linux
The cache age comes from the file's last-modified time, and stat spells that differently on the two systems: stat -c %Y on Linux, stat -f %m on macOS. The documented script tries the Linux form first and falls back to the macOS form, then to zero.
The order is deliberate. On Linux, the macOS form does not just fail: it prints a filesystem report to stdout before failing, and the command substitution captures that text. The arithmetic then receives words where it expects a number and the test breaks, so the Linux form has to run first.
If you rewrite this script for another shell, keep that ordering and keep the || echo 0 fallback. A missing cache file is handled before this line by the [ ! -f ] test, but a file the shell cannot stat still needs a numeric answer.
The settings entry
Add this to ~/.claude/settings.json, or to a project's settings file if you want the row only there.
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh",
"refreshInterval": 5
}
}Add the object beside whatever else the file holds, inside the same braces; it is not a whole file to paste over. Claude Code reloads settings and runs the script as soon as you save it.
The refreshInterval line is optional here but worth keeping for a git row. The event-driven triggers go quiet while the main session is idle, for example while the session waits on work running in the background, so git can move without the row re-running. Five seconds keeps the row ticking during idle periods; because the age test is "more than five seconds", the cache is refreshed on the first tick after it passes that age, not on the tick that reaches it.
How to confirm the cache works
First prove the row itself, with mock JSON piped into the script:
echo '{"model":{"display_name":"Opus"},"workspace":{"current_dir":"/home/you/my-app"},"session_id":"test"}' | ~/.claude/statusline.shRun it twice inside a repository with a change staged. The first run creates /tmp/statusline-git-cache-test; the second reads it. The row should be identical both times unless the file is more than five seconds old.
Then prove the cache is being used: run it twice in quick succession and read the cache file's last-modified time with stat -c %Y /tmp/statusline-git-cache-test on Linux, or stat -f %m on macOS. The two runs should leave the same time. Delete the file, run again, and it should be recreated; if both quick runs rewrite it, the name or the age test is wrong.
Inside Claude Code, claude --debug logs the script's stderr on every invocation and its exit code on the first invocation in a session, which separates a script that failed from one that ran and printed the wrong thing.
What goes wrong with the cache
| What you see | Check |
|---|---|
| No row at all | The workspace trust dialog has been accepted for the folder, the script is executable, and it prints to stdout. A non-zero exit or no output leaves the row blank |
| The row is still slow | Every run is missing the cache. Check that session_id is read and that the file name is not built from a process id |
| The branch or counts are wrong in one of two sessions | The sessions are sharing a cache file. The name is not unique, so one checkout reads the other's state |
| A filesystem report appears in the row or the arithmetic fails | The stat order. The Linux form has to run first, because the macOS form prints a report on Linux rather than failing quietly |
| The branch lags after you switch | Expected for up to five seconds; add refreshInterval so the row re-runs while the session is idle |
| Nothing is ever cached | The /tmp file may be unwritable, or another tool is cleaning it. Run the script by hand and look at the file's mtime |
The cache buys speed with a bounded staleness: five seconds in the documented example. That is the trade to make deliberately, not a bug to chase. If you need the branch exact at every moment, use the uncached git row and accept the cost.
More in this set
Each page carries a complete setup, not a fragment.
- A clickable repository link
- Rate limit usage
- One inline command โ the model and context row with no script file
- Python scripts โ the same ideas in Python
- Git branch and changes โ the same row without the cache
- The status line itself
Where Omniscio fits
The status line is Claude Code's own, and nothing on this page needs Omniscio. Omniscio is a desktop app for running several Claude Code agents side by side, in one list rather than a wall of terminals.
Its agent sessions run Claude Code in print mode, so they show Omniscio's session list rather than a terminal row. A status line you configure still applies to any claude you run yourself in a terminal.
The features page lists what the app does today.
How this page was checked
Every statement here about Claude Code comes from Anthropic's own documentation, read in its Markdown form on November 26, 2026: the status line page, the settings reference and the changelog. The version line comes from the changelog, whose newest release is 2.1.332, dated November 25, 2026.
The script is Anthropic's cache example reproduced in full, with its explanatory comments removed from the code block and kept as prose on this page. It was not written for this page and not run on our machine.
What this page says about Omniscio comes from our own pages. If Anthropic's page and this one ever disagree about Claude Code, Anthropic's page is right.
Sources
- Customize your status line: the setting, the full JSON, the update triggers, the cache example and its session id note, the Windows notes and the troubleshooting section
- Settings reference: the
statusLineentry and its fields - The changelog: release 2.1.332, the newest listed
- jq: the JSON parser the script calls
Omniscio's own pages, for what this section says about this app:
- Omniscio's homepage: the product description
- Features: what the app does today
- Claude Code status line: the setting and the payload this page assumes
Common questions
Why is my Claude Code status line slow?
The script runs frequently during active sessions, and commands like git status or git diff get slow in a large repository. A slow script blocks the row from updating until it finishes, and a new update arriving meanwhile cancels the in-flight script rather than queueing behind it. Anthropic's answer is to cache the expensive output.
What should the cache file be named?
Use the session_id from the JSON input. The name has to stay stable across invocations within one session and stay unique across sessions so two checkouts in different repositories do not read each other's cached git state. Process identifiers like $$ change on every invocation, which defeats the cache entirely.
Does the cache make the branch go stale?
It can, for up to the cache age: the documented example refreshes every five seconds. If you need the row to follow a branch change while the session sits idle, also set refreshInterval in the statusLine object, because the event-driven triggers go quiet during idle periods.
Why does the script print a filesystem report?
On Linux, the macOS form stat -f %m does not fail quietly: it prints a filesystem report to stdout before failing, and the command substitution captures that text into the arithmetic. The documented script runs the Linux form stat -c %Y first, then falls back to the macOS form, then to zero.
Run those Claude Code sessions from one window
Install Omniscio, keep your Claude Code sessions in one list, and see what each one needs without hunting through terminals. The features page lists what is in it today.