A custom statusline for Claude Code CLI that displays time, user@host, current directory, context window percentage, and token counts.
19:56:01 myname@mylaptop:my-project-dir (51% / 200k Β· 102k β Β· 15k β)
- Time - Current time (red)
- user@host:dir - User, hostname, and current directory basename
- Context info:
- 51% - Current context window usage percentage
- 200k - Total context window size
- 102k β - Total input tokens sent (session cumulative)
- 15k β - Total output tokens received (session cumulative)
Based on context percentage:
β€30%: Default color31-45%: π’ Green46-55%: π Orange56%+: π΄ Red
curl -fsSL https://gist.githubusercontent.com/andkirby/f826e5d264368308cd9d5c4c086aa96e/raw/install-statusline.sh | bash# macOS
brew install jq
# Linux
sudo apt install jq # Debian/Ubuntu
sudo yum install jq # RHEL/CentOS- Download the script:
curl -fsSL https://gist.githubusercontent.com/andkirby/f826e5d264368308cd9d5c4c086aa96e/raw/statusline-command.sh -o ~/.claude/statusline-command.sh- Make it executable:
chmod +x ~/.claude/statusline-command.sh- Add to
~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline-command.sh"
}
}Test the script manually:
echo '{"workspace":{"current_dir":"/Users/user/project"},"context_window":{"context_window_size":200000,"current_usage":{"input_tokens":70000,"cache_creation_input_tokens":1000,"cache_read_input_tokens":2000},"total_input_tokens":102000,"total_output_tokens":15000}}' | ~/.claude/statusline-command.sh- Context percentage shows 0% - Due to bug #13385,
current_usagemay return zeros. The script uses the correct property per the API docs, so it will work when the bug is fixed.
Modify color thresholds in statusline-command.sh:
if [ $context_percent -le 30 ]; then
context_color='\033[0m' # Default
elif [ $context_percent -le 45 ]; then
context_color='\033[32m' # Green
elif [ $context_percent -le 55 ]; then
context_color='\033[33m' # Orange
else
context_color='\033[31m' # Red
fi| Color | Code |
|---|---|
| Red | \033[31m |
| Green | \033[32m |
| Orange/Yellow | \033[33m |
| Blue | \033[34m |
| Reset | \033[0m |