--- /dev/null
+#!/bin/sh
+set -eux
+
+proj=$(basename $(dirname $(pwd)))
+
+prune() {
+ for branch in $(git remote prune "$1" | grep -o "$1/.*$"); do
+ branch="${branch#*/}"
+ echo "Cleaning up $branch"
+ git worktree remove --force "$branch"
+ git branch -D "$branch"
+ done
+ git worktree prune
+}
+
+case "$1" in
+ checkout) git worktree add ../$2 ;;
+ add) git worktree add ../$2 -b $2 main ;;
+ prune) prune "$2";;
+ *) echo "Unknown command $1" >&2; exit 1 ;;
+esac