From c67c89f4f795caea7b5ecca969548c3ba6b8f2f9 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 20 Feb 2026 08:32:18 -0800 Subject: [PATCH] add fish shell completions for sandlot --- completions/sandlot.fish | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 completions/sandlot.fish diff --git a/completions/sandlot.fish b/completions/sandlot.fish new file mode 100644 index 0000000..cfe0af9 --- /dev/null +++ b/completions/sandlot.fish @@ -0,0 +1,75 @@ +# Fish completions for sandlot +# Install: cp completions/sandlot.fish ~/.config/fish/completions/ + +# Helper: list active session branches from .sandlot/state.json +function __sandlot_sessions + set -l root (git rev-parse --show-toplevel 2>/dev/null) + or return + set -l state "$root/.sandlot/state.json" + test -f "$state"; or return + string match -rg '"branch":\s*"([^"]+)"' <"$state" +end + +# All top-level subcommands (used for __fish_seen_subcommand_from checks) +set -l __sandlot_cmds new list open review shell close rm merge save diff show log dir cleanup vm +set -l __sandlot_vm_cmds create start shell status info stop destroy + +# Disable file completions +complete -c sandlot -f + +# ── Top-level subcommands ──────────────────────────────────────────── + +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a new -d 'Create a new session and launch Claude' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a list -d 'Show all active sessions' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a open -d 'Re-enter an existing session' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a review -d 'Launch a code review for a branch' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a shell -d 'Open a shell in the VM' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a close -d 'Remove a worktree and clean up' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a merge -d 'Merge a branch into main and close' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a save -d 'Stage all changes and commit' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a diff -d 'Show changes for a branch' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a show -d 'Show prompt and diff for a branch' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a log -d 'Show commits not on main' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a dir -d 'Print the worktree path' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a cleanup -d 'Remove stale sessions' +complete -c sandlot -n "not __fish_seen_subcommand_from $__sandlot_cmds" -a vm -d 'Manage the sandlot VM' + +# ── Session branch completions ─────────────────────────────────────── + +for cmd in open review shell close rm merge save diff show log dir + complete -c sandlot -n "__fish_seen_subcommand_from $cmd; and not __fish_seen_subcommand_from vm" -a '(__sandlot_sessions)' +end + +# ── Command options ────────────────────────────────────────────────── + +# new +complete -c sandlot -n '__fish_seen_subcommand_from new' -s p -l print -r -d 'Run Claude non-interactively with prompt' +complete -c sandlot -n '__fish_seen_subcommand_from new' -s n -l no-save -d 'Skip auto-save after Claude exits' + +# list +complete -c sandlot -n '__fish_seen_subcommand_from list' -l json -d 'Output as JSON' + +# open +complete -c sandlot -n '__fish_seen_subcommand_from open' -s p -l print -r -d 'Run Claude non-interactively with prompt' +complete -c sandlot -n '__fish_seen_subcommand_from open' -s n -l no-save -d 'Skip auto-save after Claude exits' + +# review +complete -c sandlot -n '__fish_seen_subcommand_from review' -s p -l print -d 'Print review to stdout' + +# close / rm +complete -c sandlot -n '__fish_seen_subcommand_from close rm' -s f -l force -d 'Close even with unsaved changes' + +# ── vm subcommands ─────────────────────────────────────────────────── + +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a create -d 'Create and provision the VM' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a start -d 'Start the VM' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a shell -d 'Open a shell in the VM' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a status -d 'Show VM status' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a info -d 'Show VM system info' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a stop -d 'Stop the VM' +complete -c sandlot -n "__fish_seen_subcommand_from vm; and not __fish_seen_subcommand_from $__sandlot_vm_cmds" -a destroy -d 'Stop and delete the VM' + +# ── Global options ─────────────────────────────────────────────────── + +complete -c sandlot -s h -l help -d 'Show help' +complete -c sandlot -s V -l version -d 'Show version'