2026-09-18 13:58:49 -04:00
|
|
|
#!/usr/bin/env bash
|
2026-11-08 18:13:24 -05:00
|
|
|
# Launch OpenCode with an isolated config so it cannot rewrite
|
|
|
|
|
# ~/.config/opencode/opencode.json (firstmate).
|
2026-09-18 13:58:49 -04:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
2026-11-08 12:15:22 -05:00
|
|
|
bin="${OPENCODE2_BIN:-/opt/homebrew/opt/opencode/bin/opencode}"
|
2026-09-18 13:58:49 -04:00
|
|
|
cfg="${OPENCODE_CONFIG:-$HOME/.config/opencode2/opencode.json}"
|
|
|
|
|
|
|
|
|
|
if [ ! -x "$bin" ]; then
|
2026-11-08 12:15:22 -05:00
|
|
|
echo "oc2: stable opencode not installed. Rebuild, or run:" >&2
|
2026-11-08 18:13:24 -05:00
|
|
|
echo " brew install opencode" >&2
|
2026-09-18 13:58:49 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
if [ ! -e "$cfg" ]; then
|
|
|
|
|
echo "oc2: missing config $cfg (managed by home.nix)" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
export OPENCODE_CONFIG="$cfg"
|
|
|
|
|
exec "$bin" "$@"
|