Configuration and deployment updates to match the new feature set.
defaults.json:
- Dark theme palette switched from named ANSI to Dracula-inspired hex:
success=#50fa7b, warning=#f1fa8c, danger=#ff5555, accent=#8be9fd,
info=#bd93f9. Light theme unchanged (named ANSI with bold).
- Glyph characters normalized to Unicode escapes (clean/ahead/behind).
- Verbose layout (3 lines) reorganized:
Line 1: model, provider, spacer, lines_changed, project, vcs, beads
Line 2: context_bar, context_usage, cache_efficiency, spacer, cost,
cost_velocity, cost_trend, duration
Line 3: context_trend, tokens_raw, spacer, tools, turns, load,
cloud_profile, k8s_context, python_env, toolchain
- context_usage, cost_trend, context_trend now enabled by default.
- Trend widths increased from 8 to 12 characters.
- Context bar: bar_style=block, gradient=true.
- Tools: show_breakdown=true, top_n=7.
- New sections enabled: cloud_profile (P2), k8s_context (P3, ttl=30),
python_env (P3), toolchain (P3).
schema.json:
- Added $schema self-reference field for editor autocomplete.
- Expanded colorName from fixed enum to freeform string with docs
covering hex, bg:, modifiers, and palette refs.
- New section schemas: trendSection, contextTrendSection with width,
gradient, and threshold properties.
- context_bar: added bar_style, gradient, fill_char, empty_char.
- tools: added show_breakdown, top_n, palette array.
- All section types: added background and placeholder properties.
- Width description updated to clarify it's a max cap + fallback,
not an override.
- colorMatch additionalProperties relaxed from enum to string.
install.sh:
Complete rewrite for Rust binary workflow:
- Checks cargo and jq prerequisites.
- Builds release binary via cargo build --release.
- Installs to ~/.local/bin/claude-statusline with PATH check.
- Creates/updates ~/.claude/settings.json with statusLine command
(type: "command", --color=always, padding: 0).
- Symlinks statusline.json config if present in project.
- Removed all bash-script-era logic (symlinks, bash version checks).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
110 lines
4.3 KiB
Bash
Executable File
110 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# install.sh — Build and install claude-statusline (Rust binary)
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
INSTALL_DIR="$HOME/.local/bin"
|
|
BINARY_NAME="claude-statusline"
|
|
CLAUDE_DIR="$HOME/.claude"
|
|
SETTINGS="$CLAUDE_DIR/settings.json"
|
|
|
|
echo "claude-statusline installer"
|
|
echo "==========================="
|
|
echo ""
|
|
|
|
# ── Check toolchain ──────────────────────────────────────────────────
|
|
if ! command -v cargo &>/dev/null; then
|
|
echo "ERROR: cargo (Rust toolchain) is required but not installed."
|
|
echo " Install via: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
|
|
exit 1
|
|
fi
|
|
echo "[ok] cargo found ($(cargo --version))"
|
|
|
|
if ! command -v jq &>/dev/null; then
|
|
echo "ERROR: jq is required for settings.json updates."
|
|
echo " macOS: brew install jq"
|
|
echo " Ubuntu: sudo apt install jq"
|
|
exit 1
|
|
fi
|
|
echo "[ok] jq found"
|
|
|
|
# ── Build release binary ─────────────────────────────────────────────
|
|
echo ""
|
|
echo "Building release binary..."
|
|
(cd "$SCRIPT_DIR" && cargo build --release --quiet)
|
|
echo "[ok] Built: $(ls -lh "$SCRIPT_DIR/target/release/$BINARY_NAME" | awk '{print $5}')"
|
|
|
|
# ── Install binary ───────────────────────────────────────────────────
|
|
mkdir -p "$INSTALL_DIR"
|
|
cp "$SCRIPT_DIR/target/release/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
|
|
chmod +x "$INSTALL_DIR/$BINARY_NAME"
|
|
echo "[ok] Installed to $INSTALL_DIR/$BINARY_NAME"
|
|
|
|
# Verify it's on PATH
|
|
if ! command -v "$BINARY_NAME" &>/dev/null; then
|
|
echo "[warn] $INSTALL_DIR is not on your PATH"
|
|
echo " Add to your shell config: export PATH=\"$INSTALL_DIR:\$PATH\""
|
|
fi
|
|
|
|
# ── Configure Claude Code settings.json ──────────────────────────────
|
|
echo ""
|
|
mkdir -p "$CLAUDE_DIR"
|
|
|
|
BINARY_PATH="$INSTALL_DIR/$BINARY_NAME"
|
|
|
|
# The binary runs in a non-TTY context, so force color on.
|
|
STATUSLINE_CMD="$BINARY_PATH --color=always"
|
|
|
|
if [[ -f "$SETTINGS" ]]; then
|
|
# Update existing settings.json
|
|
CURRENT_CMD=$(jq -r '.statusLine.command // empty' "$SETTINGS" 2>/dev/null || true)
|
|
if [[ -n "$CURRENT_CMD" ]]; then
|
|
echo "[info] Current statusLine command: $CURRENT_CMD"
|
|
fi
|
|
|
|
# Write updated settings
|
|
TMP="$SETTINGS.tmp.$$"
|
|
jq --arg cmd "$STATUSLINE_CMD" '.statusLine = {"type": "command", "command": $cmd, "padding": 0}' "$SETTINGS" > "$TMP"
|
|
mv "$TMP" "$SETTINGS"
|
|
echo "[ok] Updated statusLine in $SETTINGS"
|
|
else
|
|
# Create minimal settings.json
|
|
jq -n --arg cmd "$STATUSLINE_CMD" '{"statusLine": {"type": "command", "command": $cmd, "padding": 0}}' > "$SETTINGS"
|
|
echo "[ok] Created $SETTINGS"
|
|
fi
|
|
|
|
# ── Symlink config ───────────────────────────────────────────────────
|
|
CONFIG_SRC="$SCRIPT_DIR/statusline.json"
|
|
CONFIG_DST="$CLAUDE_DIR/statusline.json"
|
|
|
|
if [[ -f "$CONFIG_SRC" ]]; then
|
|
if [[ -L "$CONFIG_DST" ]]; then
|
|
EXISTING="$(readlink "$CONFIG_DST")"
|
|
if [[ "$EXISTING" == "$CONFIG_SRC" ]]; then
|
|
echo "[ok] Config already linked"
|
|
else
|
|
ln -sf "$CONFIG_SRC" "$CONFIG_DST"
|
|
echo "[ok] Config symlink updated (was: $EXISTING)"
|
|
fi
|
|
elif [[ -f "$CONFIG_DST" ]]; then
|
|
echo "[skip] $CONFIG_DST exists as a regular file"
|
|
echo " To use the symlink, remove it first: rm $CONFIG_DST"
|
|
else
|
|
ln -s "$CONFIG_SRC" "$CONFIG_DST"
|
|
echo "[ok] Config linked: $CONFIG_DST -> $CONFIG_SRC"
|
|
fi
|
|
else
|
|
echo "[info] No statusline.json in project. To customize, create:"
|
|
echo " $CONFIG_SRC"
|
|
echo ""
|
|
echo " Print defaults: $BINARY_NAME --print-defaults"
|
|
echo " Print schema: $BINARY_NAME --config-schema"
|
|
fi
|
|
|
|
# ── Done ─────────────────────────────────────────────────────────────
|
|
echo ""
|
|
echo "Done. Restart Claude Code to see the status line."
|
|
echo ""
|
|
echo "Quick test: $BINARY_NAME --test --color=always"
|
|
echo "Debug: $BINARY_NAME --test --dump-state=json"
|