Loading...
WCAG-compliant accessible statusline with screen reader announcements, high-contrast colors, semantic labels, keyboard hints, and reduced motion support.
#!/usr/bin/env bash
# Accessibility-First Statusline for Claude Code
# WCAG 2.1 AA compliant, screen reader friendly, high contrast
# Read JSON from stdin
read -r input
# Extract values
model=$(echo "$input" | jq -r '.model // "unknown"')
dir=$(echo "$input" | jq -r '.workspace.path // "~"' | sed "s|$HOME|~|")
tokens=$(echo "$input" | jq -r '.session.totalTokens // 0')
# Check for PREFERS_REDUCED_MOTION environment variable
if [ "$PREFERS_REDUCED_MOTION" = "1" ]; then
# No animations, static display
animation=""
else
# Minimal indicator (not flashing)
animation="▪"
fi
# High contrast WCAG AA compliant colors
# Contrast ratio > 4.5:1 against black background
# Using basic ANSI colors for maximum compatibility
WHITE_BOLD="\033[1;37m" # Bright white (high contrast)
CYAN_BOLD="\033[1;36m" # Bright cyan (high contrast)
YELLOW_BOLD="\033[1;33m" # Bright yellow (high contrast)
RESET="\033[0m"
# Semantic labels (screen reader friendly)
LABEL_MODEL="Model:"
LABEL_DIR="Directory:"
LABEL_TOKENS="Tokens:"
# Build statusline with semantic structure
statusline=""
statusline+="${animation} " # Activity indicator (if motion enabled)
statusline+="${WHITE_BOLD}${LABEL_MODEL}${RESET} ${CYAN_BOLD}${model}${RESET} | "
statusline+="${WHITE_BOLD}${LABEL_DIR}${RESET} ${CYAN_BOLD}${dir}${RESET} | "
statusline+="${WHITE_BOLD}${LABEL_TOKENS}${RESET} ${YELLOW_BOLD}${tokens}${RESET}"
# Output for visual display
echo -e "$statusline"
# Screen reader announcement (stderr for assistive tech)
# Only announce on significant changes (every 1000 tokens)
token_threshold=$((tokens / 1000 * 1000))
if [ -f "/tmp/claude_statusline_last_tokens" ]; then
last_tokens=$(cat /tmp/claude_statusline_last_tokens)
else
last_tokens=0
fi
if [ $token_threshold -ne $((last_tokens / 1000 * 1000)) ]; then
# Announce to screen reader (ARIA live region style)
echo "Status update: Using $model in directory $dir. Token count: $tokens." >&2
echo $tokens > /tmp/claude_statusline_last_tokens
fi
# Keyboard navigation hint (on first run)
if [ ! -f "/tmp/claude_statusline_initialized" ]; then
echo "Accessibility mode enabled. Press Ctrl+C to interrupt, Tab for completion suggestions." >&2
touch /tmp/claude_statusline_initialized
fi{
"format": "bash",
"position": "left",
"colorScheme": "high-contrast-wcag",
"refreshInterval": 2000
}Screen reader not announcing status updates
Verify screen reader configured to read stderr. Test: echo 'test' >&2. Check /tmp/claude_statusline_last_tokens exists and updates. Adjust announcement threshold (currently 1000 tokens) in script if too frequent/infrequent.
Colors too dim or hard to read on terminal background
WCAG contrast ratios assume black/dark background. For light backgrounds, invert: Use dark colors instead. Test contrast: WebAIM contrast checker. Adjust ANSI codes: 30-37 (dark) vs 90-97 (bright). Check terminal theme.
Animation indicator (▪) showing even with reduced motion enabled
Set environment variable: export PREFERS_REDUCED_MOTION=1. Add to ~/.bashrc or ~/.zshrc for persistence. Verify: echo $PREFERS_REDUCED_MOTION (should show 1). Restart Claude Code session after setting.
Keyboard navigation hints appearing every session
Check /tmp/claude_statusline_initialized file exists and persists. Verify /tmp writable: touch /tmp/test && rm /tmp/test. On system reboot, /tmp clears - expected behavior. Move to ~/.cache/ for persistence across reboots.
Semantic labels making statusline too verbose or crowded
Labels essential for screen readers but can be shortened: 'M:' instead of 'Model:', 'D:' for 'Directory:', 'T:' for 'Tokens:'. Balance visual brevity with semantic meaning. Test with screen reader first before removing labels.
Loading reviews...