From f91586248f467a2ba7a62f76caee1f40927655d9 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 19 May 2026 13:17:06 -0500 Subject: feat(tmux-util): add rename subcommand (fzf pick + prompt) tmux-util rename closes out the original six-subcommand plan. The flow: 1. fzf-pick a session from the list. 2. Prompt for a new name on stdin. 3. Bail with a useful message on empty input, same-as-old, or conflict with an existing session. 4. Otherwise `tmux rename-session -t ` and confirm. The conflict check uses `tmux has-session -t =` with the same `=`-prefix exact-match guard as the go subcommand. Without it, tmux's default prefix matching would let `rename foo` succeed even when a session named `foobar` already exists, then surprise the user later. 5 new tests cover Normal cases (pick + rename happy path) and Boundary cases (no sessions, fzf cancel, empty new name, same-as-old no-op, conflict with existing session). The test harness's run_script grew an `stdin=` param so tests can feed the prompt input. fake-tmux picked up a rename-session handler that mutates the state file. Total suite: 48 tests, all green. Six subcommands shipped: go, pick, ls, find, reap, rename. The original "no args prints help" requirement still holds, and the stub-test for unimplemented subcommands got removed since everything's wired now. --- tests/tmux-util/fake-tmux | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/tmux-util/fake-tmux') diff --git a/tests/tmux-util/fake-tmux b/tests/tmux-util/fake-tmux index b5a1e61..1b84956 100755 --- a/tests/tmux-util/fake-tmux +++ b/tests/tmux-util/fake-tmux @@ -151,6 +151,34 @@ case "$cmd" in attach-session|switch-client) # No state mutation needed — the call log already records intent. ;; + rename-session) + # Forms: rename-session -t OR rename-session + old="" + new="" + while [ "$#" -gt 0 ]; do + case "$1" in + -t) shift; old="$1"; shift ;; + *) new="$1"; shift ;; + esac + done + if [ -z "$old" ] || [ -z "$new" ]; then + echo "fake-tmux rename-session: need both -t and " >&2 + exit 1 + fi + tmp="$STATE.tmp" + : > "$tmp" + while IFS= read -r line; do + [ -n "$line" ] || continue + first="${line%% *}" + rest="${line#* }" + if [ "$first" = "$old" ]; then + printf '%s %s\n' "$new" "$rest" >> "$tmp" + else + printf '%s\n' "$line" >> "$tmp" + fi + done < "$STATE" + mv "$tmp" "$STATE" + ;; kill-session) session="" while [ "$#" -gt 0 ]; do -- cgit v1.2.3