#!/usr/bin/env bash # install.sh — Set up claude-statusline symlinks set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CLAUDE_DIR="$HOME/.claude" echo "claude-statusline installer" echo "===========================" echo "" # Check dependencies if ! command -v jq &>/dev/null; then echo "ERROR: jq is required but not installed." echo " macOS: brew install jq" echo " Ubuntu: sudo apt install jq" echo " Fedora: sudo dnf install jq" exit 1 fi echo "[ok] jq found" # Check bash version if (( BASH_VERSINFO[0] < 4 )); then echo "WARNING: bash 4+ recommended (you have ${BASH_VERSION})" echo " macOS ships bash 3. Install bash 4+:" echo " brew install bash" fi # Ensure ~/.claude exists mkdir -p "$CLAUDE_DIR" # Create symlinks create_link() { local src="$1" dst="$2" name="$3" if [[ -L "$dst" ]]; then local existing existing="$(readlink "$dst")" if [[ "$existing" == "$src" ]]; then echo "[ok] $name already linked" return fi echo "[update] $name: updating symlink" ln -sf "$src" "$dst" elif [[ -f "$dst" ]]; then echo "[skip] $name: $dst exists as a regular file" echo " To use the symlink, rename or remove the existing file first." return else ln -s "$src" "$dst" echo "[ok] $name linked" fi } create_link "$SCRIPT_DIR/statusline.sh" "$CLAUDE_DIR/statusline.sh" "statusline.sh" # Optionally link user config if they want to start from an example if [[ ! -f "$CLAUDE_DIR/statusline.json" ]]; then echo "[info] No statusline.json found. You can copy an example from:" echo " $SCRIPT_DIR/examples/" fi echo "" echo "Symlinks created. Now add the status line to your Claude Code settings." echo "" echo "Add this to ~/.claude/settings.json:" echo "" echo ' "statusLine": "'$CLAUDE_DIR'/statusline.sh"' echo "" echo "If ~/.claude/settings.json doesn't exist yet, create it:" echo "" echo ' {' echo ' "statusLine": "'$CLAUDE_DIR'/statusline.sh"' echo ' }' echo "" echo "Then restart Claude Code to see the status line."