Loading...
Ultra-lightweight plain text statusline with no colors or special characters for maximum compatibility and minimal overhead
#!/usr/bin/env bash
# Simple Text Statusline for Claude Code
# Plain text only - maximum compatibility
# Read JSON from stdin
read -r input
# Extract values using bash built-ins (no jq required)
model=$(echo "$input" | grep -o '"model":"[^"]*"' | cut -d'"' -f4)
dir=$(echo "$input" | grep -o '"path":"[^"]*"' | cut -d'"' -f4 | sed "s|$HOME|~|")
tokens=$(echo "$input" | grep -o '"totalTokens":[0-9]*' | cut -d':' -f2)
# Default values if extraction fails
model=${model:-"unknown"}
dir=${dir:-"~"}
tokens=${tokens:-"0"}
# Build simple plain text status
echo "[Model: $model] [Dir: $dir] [Tokens: $tokens]"
{
"format": "bash",
"position": "left",
"refreshInterval": 300
}Values showing as empty or 'unknown'
JSON parsing relies on specific format. Ensure Claude Code is outputting standard JSON. Test with: echo '$input' to see raw JSON.
Home directory not shortened to ~
Check that $HOME environment variable is set correctly: echo $HOME. If using sudo, HOME may not be preserved.
grep or cut command not found
These are standard POSIX utilities. Install coreutils package: apt install coreutils (Linux) or ensure busybox is installed (embedded systems).
JSON parsing breaks when Claude Code changes output format
grep/cut parsing is fragile. Switch to jq-based statusline or use awk: awk 'BEGIN { FS="\""; RS="," }; { if ($2 == "model") {print $4} }' for robust parsing.
HOME not preserved when running script with sudo
Use sudo -H to set HOME or sudo -E to preserve variables. Add HOME to env_keep in /etc/sudoers for persistent fix. Test: sudo -H bash script.sh.
Loading reviews...