-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_opencode_config.sh
More file actions
executable file
·66 lines (52 loc) · 1.45 KB
/
Copy pathsetup_opencode_config.sh
File metadata and controls
executable file
·66 lines (52 loc) · 1.45 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
#!/usr/bin/env bash
set -euo pipefail
DOTFILES_OPENCODE="$HOME/dotfiles/opencode"
OPENCODE_DIR="$HOME/.config/opencode"
CONFIG_FILES=(
"opencode.jsonc"
"dcp.jsonc"
"AGENTS.md"
)
CONFIG_DIRS=(
"agents"
"commands"
"plugins"
"skills"
)
echo "Setting up opencode configuration symlinks..."
mkdir -p "$OPENCODE_DIR"
for file in "${CONFIG_FILES[@]}"; do
SOURCE="$DOTFILES_OPENCODE/$file"
TARGET="$OPENCODE_DIR/$file"
if [ -e "$SOURCE" ]; then
if [ -e "$TARGET" ] && [ ! -L "$TARGET" ]; then
echo "Backing up existing $file to $file.backup"
mv "$TARGET" "$TARGET.backup"
fi
[ -L "$TARGET" ] && rm "$TARGET"
echo "Symlinking $file"
ln -s "$SOURCE" "$TARGET"
else
echo "Warning: $SOURCE not found, skipping"
fi
done
for dir in "${CONFIG_DIRS[@]}"; do
SOURCE="$DOTFILES_OPENCODE/$dir"
TARGET="$OPENCODE_DIR/$dir"
if [ -d "$SOURCE" ]; then
if [ -d "$TARGET" ] && [ ! -L "$TARGET" ]; then
echo "Backing up existing $dir/ to $dir.backup/"
mv "$TARGET" "$TARGET.backup"
fi
[ -L "$TARGET" ] && rm "$TARGET"
echo "Symlinking $dir/"
ln -s "$SOURCE" "$TARGET"
else
echo "Warning: $SOURCE not found, skipping"
fi
done
echo ""
echo "opencode configuration setup complete!"
echo ""
echo "Symlinked files:"
find "$OPENCODE_DIR" -maxdepth 1 -type l -lname "*$DOTFILES_OPENCODE*" -ls