# pi-utils.zsh — the "pir" walkthrough result # Built live at the workshop following the same recipe as the x/xr family. # Source it: source demo/pi-utils.zsh then run: pi- # Recipe step 0 — the base wrapper already exists in the dotfiles # (~/.config/zsh/local.zsh): pi() heals a lockfile bug, then execs the real # pi binary. Every helper below composes on top of `pi`, never the raw binary. # Recipe step 1 — read the CLI's own session flags: # pi --help | grep -E "resume|continue|fork|name" # --continue, -c Continue previous session # --resume, -r Select a session to resume # --fork Fork a session into a new session # --name, -n Set session display name # Recipe step 2 — wrap each flag as a two/three-letter function. unalias pir 2>/dev/null pir() { pi --resume "$@"; } # pick a session to resume (pi resume) unalias pic 2>/dev/null pic() { pi --continue "$@"; } # continue the most recent session unalias pif 2>/dev/null pif() { pi --fork "$@"; } # fork a session: pif [prompt] unalias pin 2>/dev/null pin() { # start a named session: pin [prompt] local name="${1:?Usage: pin [prompt...]}"; shift pi --name "$name" "$@" } unalias pit 2>/dev/null pit() { pi --no-session "$@"; } # throwaway session (nothing saved) # Recipe step 3 — every family ships its own cheat sheet (the x- convention). pi-() { local -a fn_name=(pi pir pic pif pin pit) local -A fn_desc=( pi 'Base wrapper: heals the auth.json.lock bug, then runs the pi binary.' pir 'Resume: open the session picker (pi --resume).' pic 'Continue: jump straight back into the last session (pi --continue).' pif 'Fork a session into a new one: pif [prompt].' pin 'Start a named session: pin [prompt].' pit 'Throwaway: run without saving a session (pi --no-session).' ) local fn for fn in "${fn_name[@]}"; do printf '%-4s %s\n' "$fn" "${fn_desc[$fn]}" done }