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/swap-pane | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tmuxrdr/plugin/bin/swap-pane (limited to 'tmuxrdr/plugin/bin/swap-pane') diff --git a/tmuxrdr/plugin/bin/swap-pane b/tmuxrdr/plugin/bin/swap-pane new file mode 100755 index 00000000..636c9904 --- /dev/null +++ b/tmuxrdr/plugin/bin/swap-pane @@ -0,0 +1,30 @@ +#!/bin/sh +# tmux prefix+{ / prefix+} (swap-pane -U / -D): swap the current pane with the +# previous / next one in pane-index order, wrapping; `marked` swaps with the +# pane prefix+m marked (swap-pane with no target, from the : prompt). The +# current pane keeps focus as it moves, as in tmux. +. "$(dirname "$0")/../lib.sh" + +p="$(active_pane)" +case "${1:-}" in +marked) + t="$(cat "$(state_dir)/marked" 2>/dev/null || true)" + [ -n "$t" ] && "$H" pane get "$t" >/dev/null 2>&1 || fail "no marked pane" + ;; +prev | next) + panes="$(tab_panes "$p")" + n="$(printf '%s\n' "$panes" | wc -l | tr -d ' ')" + [ "$n" -gt 1 ] || exit 0 + i="$(printf '%s\n' "$panes" | grep -n -x -F "$p" | cut -d: -f1)" + if [ "$1" = prev ]; then + j=$(( (i - 2 + n) % n + 1 )) + else + j=$(( i % n + 1 )) + fi + t="$(printf '%s\n' "$panes" | sed -n "${j}p")" + ;; +*) + fail "usage: swap-pane prev|next|marked" + ;; +esac +[ "$t" = "$p" ] || swap "$p" "$t" -- cgit v1.2.3