diff --git a/.claude/scripts/sync.sh b/.claude/scripts/sync.sh index f7e6a89..59c2b8b 100755 --- a/.claude/scripts/sync.sh +++ b/.claude/scripts/sync.sh @@ -22,13 +22,20 @@ TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S") echo -e "${GREEN}[OK]${NC} Starting ClaudeTools sync from $MACHINE at $TIMESTAMP" -# Navigate to ClaudeTools directory (check common locations) -for candidate in "$HOME/ClaudeTools" "/d/ClaudeTools" "D:/ClaudeTools" "/d/claudetools" "D:/claudetools" "C:/claudetools" "/c/claudetools"; do - if [ -d "$candidate" ]; then - cd "$candidate" - break - fi -done +# Navigate to ClaudeTools directory +# First check: are we already in the repo (or a subdirectory of it)? +REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || true) +if [ -n "$REPO_ROOT" ]; then + cd "$REPO_ROOT" +else + # Fall back to known candidate paths + for candidate in "$HOME/ClaudeTools" "/d/ClaudeTools" "D:/ClaudeTools" "/d/claudetools" "D:/claudetools" "C:/claudetools" "/c/claudetools"; do + if [ -d "$candidate/.git" ]; then + cd "$candidate" + break + fi + done +fi if [ ! -d ".git" ]; then echo -e "${RED}[ERROR]${NC} Not in a git working tree"