-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·117 lines (100 loc) · 4.15 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·117 lines (100 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
# claude-sync installer
# Usage: curl -fsSL https://raw.githubusercontent.com/SamTerces/claude-sync/main/install.sh | bash
set -euo pipefail
REPO="SamTerces/claude-sync"
RAW="https://raw.githubusercontent.com/${REPO}/main"
SKILLS_DIR="${HOME}/.claude/skills/claude-sync"
BIN_DIR="${HOME}/.local/bin"
VERSION="1.0.0"
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'
BOLD='\033[1m'; DIM='\033[2m'; NC='\033[0m'
info() { echo -e "${CYAN}→${NC} $*"; }
ok() { echo -e "${GREEN}✓${NC} $*"; }
err() { echo -e "${RED}✗${NC} $*" >&2; exit 1; }
bold() { echo -e "${BOLD}$*${NC}"; }
dim() { echo -e "${DIM}$*${NC}"; }
fetch() {
local url="$1" dst="$2"
if command -v curl &>/dev/null; then
curl -fsSL "${url}" -o "${dst}"
elif command -v wget &>/dev/null; then
wget -qO "${dst}" "${url}"
else
err "Neither curl nor wget found. Install one and retry."
fi
}
check_deps() {
command -v git &>/dev/null || err "git is required. Install: https://git-scm.com"
command -v claude &>/dev/null || {
echo ""
echo -e "${RED}⚠${NC} Claude Code not found."
dim " Install it from: https://claude.ai/code"
echo ""
exit 1
}
}
install_skill() {
info "Downloading skill files..."
mkdir -p "${SKILLS_DIR}/scripts" "${SKILLS_DIR}/references"
fetch "${RAW}/skills/claude-sync/SKILL.md" "${SKILLS_DIR}/SKILL.md"
fetch "${RAW}/skills/claude-sync/REFERENCE.md" "${SKILLS_DIR}/REFERENCE.md"
fetch "${RAW}/skills/claude-sync/EXAMPLES.md" "${SKILLS_DIR}/EXAMPLES.md"
fetch "${RAW}/skills/claude-sync/scripts/sync.sh" "${SKILLS_DIR}/scripts/sync.sh"
fetch "${RAW}/skills/claude-sync/references/merge-strategy.md" "${SKILLS_DIR}/references/merge-strategy.md"
fetch "${RAW}/skills/claude-sync/references/conflict-resolution.md" "${SKILLS_DIR}/references/conflict-resolution.md"
fetch "${RAW}/skills/claude-sync/references/security.md" "${SKILLS_DIR}/references/security.md"
chmod +x "${SKILLS_DIR}/scripts/sync.sh"
ok "Skill installed → ${SKILLS_DIR}/"
}
install_bin() {
info "Installing CLI..."
mkdir -p "${BIN_DIR}"
cat > "${BIN_DIR}/claude-sync" <<EOF
#!/usr/bin/env bash
exec "${SKILLS_DIR}/scripts/sync.sh" "\$@"
EOF
chmod +x "${BIN_DIR}/claude-sync"
ok "CLI installed → ${BIN_DIR}/claude-sync"
}
ensure_path() {
echo "${PATH}" | grep -q "${BIN_DIR}" && return
local rc
case "${SHELL}" in
*/zsh) rc="${HOME}/.zshrc" ;;
*/fish) rc="${HOME}/.config/fish/config.fish" ;;
*) rc="${HOME}/.bashrc" ;;
esac
printf '\n# claude-sync\nexport PATH="${HOME}/.local/bin:${PATH}"\n' >> "${rc}"
echo -e "${CYAN}→${NC} Added ${BIN_DIR} to PATH in ${rc}"
echo -e "${DIM} Run: source ${rc}${NC}"
}
verify() {
local v; v=$("${BIN_DIR}/claude-sync" version 2>/dev/null || echo "unknown")
ok "Verified: ${v}"
}
main() {
echo ""
bold " claude-sync v${VERSION}"
dim " Sync your Claude brain across machines and teammates"
echo ""
check_deps
install_skill
install_bin
ensure_path
verify
echo ""
printf "${GREEN}┌%s┐${NC}\n" "─────────────────────────────────────────────"
printf "${GREEN}│${NC} ${BOLD}%-43s${NC}${GREEN}│${NC}\n" "claude-sync installed"
printf "${GREEN}├%s┤${NC}\n" "─────────────────────────────────────────────"
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" ""
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" "1. claude-sync init <git-remote-url>"
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" "2. claude-sync push"
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" "3. On another machine: claude-sync pull"
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" ""
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" "Inside Claude Code: /sync push"
printf "${GREEN}│${NC} %-43s${GREEN}│${NC}\n" ""
printf "${GREEN}└%s┘${NC}\n" "─────────────────────────────────────────────"
echo ""
}
main "$@"