-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·44 lines (40 loc) · 1.39 KB
/
Copy pathsync.sh
File metadata and controls
executable file
·44 lines (40 loc) · 1.39 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
#!/usr/bin/env bash
# Symlink every skill in this repo into ~/.claude/skills (Claude Code) and
# ~/.agents/skills (Codex, Gemini CLI, ...), one symlink per skill.
# Idempotent: correct links are left alone, stale links are re-pointed,
# real files/dirs are never clobbered (warned and skipped).
set -euo pipefail
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGETS=("$HOME/.claude/skills" "$HOME/.agents/skills")
# Every dir holding a SKILL.md: top-level skills (./<name>/SKILL.md) and
# plugin-bundled skills (./<plugin>/skills/<name>/SKILL.md).
skill_dirs() {
find "$REPO_DIR" -mindepth 2 -maxdepth 4 -name SKILL.md \
-not -path "*/node_modules/*" -not -path "*/.git/*" \
| xargs -n1 dirname | sort -u
}
link() { # $1=skill dir, $2=target parent
local src="$1" name dest
name="$(basename "$1")"
dest="$2/$name"
if [[ -L "$dest" ]]; then
if [[ "$(readlink "$dest")" == "$src" ]]; then
echo " ok $dest"
else
ln -sfn "$src" "$dest"
echo " updated $dest -> $src (was $(readlink "$dest" 2>/dev/null || echo '?'))"
fi
elif [[ -e "$dest" ]]; then
echo " SKIP $dest exists and is not a symlink — resolve by hand" >&2
else
ln -s "$src" "$dest"
echo " linked $dest -> $src"
fi
}
for target in "${TARGETS[@]}"; do
mkdir -p "$target"
echo "$target"
while IFS= read -r dir; do
link "$dir" "$target"
done < <(skill_dirs)
done