aboutsummaryrefslogtreecommitdiff
path: root/tests/tmux-util/fake-tmux
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tmux-util/fake-tmux')
-rwxr-xr-xtests/tmux-util/fake-tmux28
1 files changed, 28 insertions, 0 deletions
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 <old> <new> OR rename-session <new>
+ 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 <old> and <new>" >&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