From 876ad3e3b8db7a554602b535cf16703409fdc6bb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 18 Jul 2026 20:38:51 +0300 Subject: tmux: add Prefix+X to kill current session and attach to next Bind Prefix+X to capture the current session name, switch the client to the next available session (switch-client -n), then kill the old session. Switching before killing keeps the client attached instead of detaching it. Placed next to the other session-management bindings and commented with the ordering rationale. Co-Authored-By: Claude Opus 4.8 --- tmux/tmux.conf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 8d3222c..6a40dfe 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -43,6 +43,14 @@ bind-key @ run-shell 'cur=$(tmux display-message -p "#S"); case "$cur" in A-*) t bind-key O run-shell 'tmux-cycle-a-session next' bind-key I run-shell 'tmux-cycle-a-session prev' +# Kill the current session and attach the client to the next available one. +# Order matters: capture the current name first, hop to the next session with +# switch-client -n, THEN kill the old session. Switching before killing keeps +# the client attached instead of detaching it (killing the session a client is +# on would otherwise drop you back to the shell). If this is the last session, +# switch-client -n is a no-op and killing it detaches the client, as expected. +bind-key X run-shell 'cur=$(tmux display-message -p "#S"); tmux switch-client -n; tmux kill-session -t "$cur"' + set-option -g pane-active-border-style fg=magenta,bold set -g status-right '#{@hexai_status} #[fg=colour8]| %H:%M' -- cgit v1.2.3