From 986e760687a2d34051934d410bec71fa2efc349b Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Mon, 5 Oct 2026 11:27:00 +0300 Subject: tmuxrdr: tmux-mode plugin The tmux default prefix bindings herdr has no built-in action for, as a herdr plugin built on its CLI and socket: break-pane, swap-pane and rotate-window by pane order (focus behaviour measured on tmux 3.7c), mark/clear-mark, last-window and switch-client -l (from focus events, per session), select-window and move-window by index, paste-buffer -p, display-message in tmux's default format, select-layout -E, kill-pane and kill-window behind tmux's y/n prompts, a command prompt taking tmux's commands, clock-mode, show-messages, and automatic-rename. Also a .gitignore for secrets scoped to tmuxrdr/, leaving herdr's own untouched. --- tmuxrdr/plugin/bin/rotate-window | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tmuxrdr/plugin/bin/rotate-window (limited to 'tmuxrdr/plugin/bin/rotate-window') diff --git a/tmuxrdr/plugin/bin/rotate-window b/tmuxrdr/plugin/bin/rotate-window new file mode 100755 index 00000000..2457fa3b --- /dev/null +++ b/tmuxrdr/plugin/bin/rotate-window @@ -0,0 +1,34 @@ +#!/bin/sh +# tmux prefix+C-o (rotate-window, upward) and prefix+M-o (rotate-window -D): +# every pane moves one place in pane-index order, wrapping. Measured on tmux +# 3.7c: %0 %1 %2 becomes %1 %2 %0 upward, %2 %0 %1 downward, and focus stays on +# the *position* -- the pane now there becomes current -- so this refocuses it +# by id over the socket (pane.focus, which the CLI does not wrap). +. "$(dirname "$0")/../lib.sh" + +p="$(active_pane)" +panes="$(tab_panes "$p")" +n="$(printf '%s\n' "$panes" | wc -l | tr -d ' ')" +[ "$n" -gt 1 ] || exit 0 +pos="$(printf '%s\n' "$panes" | grep -n -x -F "$p" | cut -d: -f1)" + +# Swaps move panes, ids and all: swapping the first pane with each of the +# others in turn rotates upward; the last with each, in reverse, downward. +case "${1:-up}" in +up) + first="$(printf '%s\n' "$panes" | sed -n 1p)" + printf '%s\n' "$panes" | sed 1d | while IFS= read -r t; do + swap "$first" "$t" + done + ;; +down) + last="$(printf '%s\n' "$panes" | sed -n "${n}p")" + printf '%s\n' "$panes" | sed '$d' | sed -n '1!G;h;$p' | while IFS= read -r t; do + swap "$last" "$t" + done + ;; +*) + fail "usage: rotate-window up|down" + ;; +esac +focus_pane "$(tab_panes "$p" | sed -n "${pos}p")" -- cgit v1.2.3