#!/bin/bash # # Purpose : Install Claude Code using the official native installer set -euo pipefail # Check if Claude Code is already installed if command -v claude &>/dev/null; then echo "Claude Code is already installed: $(claude --version)" else echo "Installing Claude Code..." curl -fsSL https://claude.ai/install.sh | bash fi # The native installer places the binary in ~/.local/bin LINE='export PATH="$HOME/.local/bin:$PATH"' if grep -qF "$LINE" ~/.bashrc; then echo "\~/.local/bin already on PATH in .bashrc" else echo "$LINE" >> ~/.bashrc echo "\~/.local/bin added to PATH in .bashrc" fi # Desktop notifications, through system/claude-notify so that clicking one # brings back the app Claude is running in SETTINGS_FILE="$HOME/.claude/settings.json" # The hook runs in a shell, which expands ~ # shellcheck disable=SC2088 NOTIFY="~/.local/share/coredesktop/system/claude-notify" if [ -f "$SETTINGS_FILE" ]; then echo "Claude Code settings already exist at $SETTINGS_FILE" # Settings written before claude-notify ran notify-send itself, so clicking # did nothing. Change those two hooks, and only those: any others are yours. tmp="$(mktemp "$SETTINGS_FILE.XXXXXX")" if jq --arg notify "$NOTIFY" \ --arg old_input "notify-send 'Claude Code' 'Needs your input'" \ --arg old_done "notify-send 'Claude Code' 'Task completed'" ' def swap(old; new): if type == "object" and .command == old then .command = new else . end; (.hooks.Notification[]?.hooks[]?) |= swap($old_input; "\($notify) '"'Needs your input'"'") | (.hooks.Stop[]?.hooks[]?) |= swap($old_done; "\($notify) '"'Task completed'"'") ' "$SETTINGS_FILE" > "$tmp" \ && ! jq -e --slurpfile new "$tmp" '. == $new[0]' "$SETTINGS_FILE" > /dev/null; then echo "Making Claude Code's notifications clickable..." mv -f "$tmp" "$SETTINGS_FILE" else rm -f "$tmp" fi else echo "Writing Claude Code settings to $SETTINGS_FILE..." mkdir -p "$(dirname "$SETTINGS_FILE")" cat > "$SETTINGS_FILE" <