claude-hooks/hooks-v2/sync-to-hub.sh

37 lines
1.2 KiB
Bash

#!/bin/bash
# Alle 2min: lokale Claude-Änderungen → git.consoro.eu/barby/claude-config
# Synct: memory/, skills/, hooks-v2/ — KEINE Credentials/Sessions/Cache
REPO_DIR="$HOME/git/claude-config"
CLAUDE_DIR="$HOME/.claude"
[ ! -d "$REPO_DIR/.git" ] && exit 0
# Relevante Dirs kopieren (kein Cache, keine Sessions, keine Credentials)
rsync -a --delete \
--exclude="*.jsonl" \
--exclude="cache/" \
--exclude="session-env/" \
--exclude="sessions/" \
--exclude="logs/" \
--exclude="log/" \
--exclude="mcp-needs-auth-cache.json" \
--exclude=".last-update" \
"$CLAUDE_DIR/projects/" "$REPO_DIR/projects/" 2>/dev/null
rsync -a --delete "$CLAUDE_DIR/hooks-v2/" "$REPO_DIR/hooks-v2/" 2>/dev/null
rsync -a --delete "$CLAUDE_DIR/skills/" "$REPO_DIR/skills/" 2>/dev/null
# Status-Datei aus Claude_desktop falls vorhanden
STATUS_SRC="/Users/matthiaskoerner/Library/Mobile Documents/com~apple~CloudDocs/Claude_desktop/status.md"
[ -f "$STATUS_SRC" ] && cp "$STATUS_SRC" "$REPO_DIR/status.md"
cd "$REPO_DIR" || exit 1
git add -A
git diff --cached --quiet && exit 0 # nix geändert
HOSTNAME=$(hostname -s)
git commit -m "auto-sync $HOSTNAME $(date '+%H:%M:%S')" \
--author="Barby <barby@consoro.eu>" -q
git push origin main -q 2>&1 | logger -t claude-sync