Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
40 lines (34 loc) · 1.55 KB
/
Copy pathinstall.sh
File metadata and controls
40 lines (34 loc) · 1.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
#!/usr/bin/env bash
# Install opencode-move-session-plugin into ~/.config/opencode/ (Linux/macOS).
# Only copies two files. Legacy opencode-move-session / -ps files are warned
# about but never removed without explicit consent (--remove-legacy).
set -euo pipefail
DEST="${OPENCODE_CONFIG_DIR:-$HOME/.config/opencode}"
SRC="$(cd "$(dirname "$0")" && pwd)"
mkdir -p "$DEST/plugins" "$DEST/commands"
cp "$SRC/plugins/move-session.js" "$DEST/plugins/"
cp "$SRC/commands/move-session.md" "$DEST/commands/"
echo "installed: $DEST/plugins/move-session.js"
echo "installed: $DEST/commands/move-session.md"
# Legacy files from opencode-move-session (bash) or opencode-move-session-ps
# (PowerShell). They define the same /move-session command and conflict with
# this plugin.
LEGACY=()
[ -f "$DEST/plugins/session-env.js" ] && LEGACY+=("$DEST/plugins/session-env.js")
[ -f "$DEST/plugins/move-session-auto-undo.js" ] && LEGACY+=("$DEST/plugins/move-session-auto-undo.js")
[ -f "$DEST/commands/move-session.ps1" ] && LEGACY+=("$DEST/commands/move-session.ps1")
if [ "${#LEGACY[@]}" -gt 0 ]; then
if [ "${1:-}" = "--remove-legacy" ]; then
for f in "${LEGACY[@]}"; do
rm -f "$f"
echo "removed legacy: $f"
done
else
echo "" >&2
echo "WARNING: legacy move-session files detected; they will conflict with this plugin:" >&2
for f in "${LEGACY[@]}"; do echo " $f" >&2; done
echo "Remove them manually (or re-run: $0 --remove-legacy), then restart opencode." >&2
fi
fi
echo ""
echo "Restart opencode for changes to take effect."