Aller au contenu principal

Claudehack v1.0

The status line that tells you where you are.

What it is

A custom bash script that replaces Claude Code's default status line with a channel-aware, cost-tracking, context-percentage display.

Requires: jq (JSON processor)

#redthread · Opus 4.6 · $2.987 · 54% context · ⟵ —

Components

FieldSourcePurpose
#channelDetected from working directoryWhich branch of the tree you're on
ModelClaude Code JSON .model.display_nameWhich model is active
$costClaude Code JSON .cost.total_cost_usdSession spend so far
N% contextClaude Code JSON .context_window.used_percentageHow full the context window is
⟵ messageClaude Code JSON .last_user_messageLast user input (truncated)

Channel Detection

The channel is derived from the current working directory:

Directory patternChannel
*/redthread*#redthread
*/ocapistaine*#jnxmas
*/vaettir*#jnxmas
*/soeurise*#soeurise
*/sovereignty*#sovereignty
*/joie-home* or */dummit*#dummiþ
*/informatique*#école
*/audierne*#audierne
*/docs* or *locki*#jnxmas
anything else#vaettir

Visual Context Bar

Green  (< 50%):  ███████░░░░░░░░
Yellow (50-80%): ██████████░░░░░
Red (> 80%): █████████████░░

Files

FileLocationPurpose
statusline.sh~/.claude/statusline.shThe script itself
settings.json~/.claude/settings.jsonClaude Code config that activates it

settings.json (relevant section)

{
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh",
"padding": 2
}
}

Backup

Both files are backed up to Synology NAS via PRIVATE_backup_synology.sh:

  • ~/.claude/settings.json — synced since initial backup script
  • ~/.claude/statusline.sh — added 2026-03-24 (existence-checked)

Install

# 1. Place the script
cp statusline.sh ~/.claude/statusline.sh
chmod +x ~/.claude/statusline.sh

# 2. Add to settings.json (merge with existing)
# See settings.json section above

# 3. Restart Claude Code — the status line appears

The Script

Source: ~/.claude/statusline.sh

#!/bin/bash
# Vaettir Status Line — Claudehack v1.0
# Reads Claude Code JSON from stdin, displays channel + model + context

input=$(cat)

MODEL=$(echo "$input" | jq -r '.model.display_name // "unknown"')
PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
CWD=$(echo "$input" | jq -r '.cwd // ""')

# Detect channel from working directory
CHANNEL=""
case "$CWD" in
*/joie-home*|*/dummit*) CHANNEL="#dummiþ" ;;
*/redthread*) CHANNEL="#redthread" ;;
*/ocapistaine*) CHANNEL="#jnxmas" ;;
*/vaettir*) CHANNEL="#jnxmas" ;;
*/soeurise*) CHANNEL="#soeurise" ;;
*/sovereignty*) CHANNEL="#sovereignty" ;;
*/informatique*) CHANNEL="#école" ;;
*/audierne*) CHANNEL="#audierne" ;;
*/docs*|*locki*) CHANNEL="#jnxmas" ;;
*) CHANNEL="#vaettir" ;;
esac

LAST_INPUT=$(echo "$input" | jq -r '.last_user_message // ""' | head -1 | cut -c1-60)
if [ -z "$LAST_INPUT" ]; then LAST_INPUT="—"; fi

BAR_LEN=15
FILLED=$((PCT * BAR_LEN / 100))
EMPTY=$((BAR_LEN - FILLED))
BAR=$(printf '█%.0s' $(seq 1 $FILLED 2>/dev/null))$(printf '░%.0s' $(seq 1 $EMPTY 2>/dev/null))

if [ "$PCT" -lt 50 ]; then COLOR="\033[32m"
elif [ "$PCT" -lt 80 ]; then COLOR="\033[33m"
else COLOR="\033[31m"; fi
RESET="\033[0m"; BOLD="\033[1m"; DIM="\033[2m"; CYAN="\033[36m"

echo -e "${BOLD}${CYAN}${CHANNEL}${RESET} ${DIM}·${RESET} ${MODEL} ${DIM}· \$${COST}${RESET}"
echo -e "${COLOR}${BAR}${RESET} ${DIM}${PCT}% context${RESET} ${DIM}· ⟵ ${LAST_INPUT}${RESET}"

Why "Claudehack"

A hack in the original sense — a clever, minimal modification that makes a tool do something its designers didn't explicitly intend. One bash script, one JSON config line, and the terminal becomes the tree's pulse monitor.

Version History

VersionDateWhat changed
v1.02026-03-23Initial: channel detection, model, cost, context bar, color coding