[Bug] DOCS: Unicode characters corrupted in statusline.sh example script
There is a bug with the first statusline.sh script listed on https://code.claude.com/docs/en/statusline
It sends unicode through tr which, at least on Linux, transforms the unicode into something unrecognizable.
Here is a fixed version of the script (tested):
#!/bin/bash
# See https://code.claude.com/docs/en/statusline
# Read all of stdin into a variable
input=$(cat)
# Extract fields with jq, "// 0" provides fallback for null
MODEL=$(echo "$input" | jq -r '.model.display_name')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
# Build progress bar
BAR_WIDTH=10
FILLED=$((PCT * BAR_WIDTH / 100))
EMPTY=$((BAR_WIDTH - FILLED))
BAR=""
[ "$FILLED" -gt 0 ] && printf -v _F "%${FILLED}s" && BAR="${_F// /▓}"
[ "$EMPTY" -gt 0 ] && printf -v _E "%${EMPTY}s" && BAR="${BAR}${_E// /░}"
echo "[$MODEL] $BAR $PCT%"
This script fixes the unicode problem, and also accelerates the script by not running tr or sed (just stays in bash).
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗