-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-skills.sh
More file actions
executable file
·89 lines (74 loc) · 2.55 KB
/
Copy pathinstall-skills.sh
File metadata and controls
executable file
·89 lines (74 loc) · 2.55 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
#!/usr/bin/env bash
# Install skills to ~/.claude/skills and ~/.codex/skills
# This script copies all skill directories to the Claude and Codex skills
# directories, replacing any existing versions.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILLS_DIR="$SCRIPT_DIR/skills"
TARGET_DIRS=("$HOME/.claude/skills" "$HOME/.codex/skills")
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Find all directories containing SKILL.md
skill_dirs=()
while IFS= read -r skill_file; do
skill_dir="$(dirname "$skill_file")"
skill_dirs+=("$skill_dir")
done < <(find "$SKILLS_DIR" -maxdepth 2 -name "SKILL.md" -type f)
# Build list of installed skill names
installed_names=()
for skill_path in "${skill_dirs[@]}"; do
installed_names+=("$(basename "$skill_path")")
done
for TARGET_DIR in "${TARGET_DIRS[@]}"; do
echo "Installing skills to $TARGET_DIR"
echo
# Create target directory if it doesn't exist
mkdir -p "$TARGET_DIR"
# Get list of existing skills before installation
existing_skills=()
if [ -d "$TARGET_DIR" ]; then
while IFS= read -r -d '' dir; do
existing_skills+=("$(basename "$dir")")
done < <(find "$TARGET_DIR" -mindepth 1 -maxdepth 1 -type d -print0)
fi
# Copy each skill directory
for skill_path in "${skill_dirs[@]}"; do
skill_name="$(basename "$skill_path")"
target_path="$TARGET_DIR/$skill_name"
if [ -d "$target_path" ]; then
echo -e "${YELLOW}Replacing${NC} $skill_name"
rm -rf "$target_path"
else
echo -e "${GREEN}Installing${NC} $skill_name"
fi
cp -r "$skill_path" "$target_path"
done
# Delete old skills that are no longer in the source
deleted_count=0
for existing in "${existing_skills[@]}"; do
found=false
for installed in "${installed_names[@]}"; do
if [ "$existing" = "$installed" ]; then
found=true
break
fi
done
if [ "$found" = false ]; then
echo -e "${YELLOW}Deleting${NC} $existing (no longer in source)"
rm -rf "$TARGET_DIR/$existing"
((deleted_count++)) || true
fi
done
echo
echo -e "${GREEN}✓${NC} Successfully installed ${#skill_dirs[@]} skill(s)"
if [ "$deleted_count" -gt 0 ]; then
echo -e "${YELLOW}✓${NC} Deleted $deleted_count old skill(s)"
fi
echo
done
echo "Installed skills:"
for skill_path in "${skill_dirs[@]}"; do
echo " - $(basename "$skill_path")"
done