diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-05 11:27:00 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-05 11:27:00 +0300 |
| commit | 986e760687a2d34051934d410bec71fa2efc349b (patch) | |
| tree | f57dcc4ba0d7690fdf90eeb2f0970a8ebbefc45a /tmuxrdr/plugin/bin/spread-layout | |
| parent | 7b116c05bfda646af39d2524c54e70c751f57ee8 (diff) | |
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.
Diffstat (limited to 'tmuxrdr/plugin/bin/spread-layout')
| -rwxr-xr-x | tmuxrdr/plugin/bin/spread-layout | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tmuxrdr/plugin/bin/spread-layout b/tmuxrdr/plugin/bin/spread-layout new file mode 100755 index 00000000..2b40de2a --- /dev/null +++ b/tmuxrdr/plugin/bin/spread-layout @@ -0,0 +1,25 @@ +#!/bin/sh +# tmux prefix+E (select-layout -E): spread panes out evenly. tmux evens out the +# current pane and its neighbours; this evens every split in the tab -- each +# split's ratio becomes its share of the panes along that direction -- over +# the socket's layout.set_split_ratio, which keeps every pane running. herdr +# clamps ratios to 0.1-0.9, so past ten panes in a row they cannot be equal. +. "$(dirname "$0")/../lib.sh" + +tab="$(pane_info "$(active_pane)" tab_id)" +api "{\"id\":\"tmux-mode\",\"method\":\"layout.export\",\"params\":{\"tab_id\":\"$tab\"}}" \ + | jq -c --arg tab "$tab" ' + def cells($d): if .type == "split" and .direction == $d + then (.first | cells($d)) + (.second | cells($d)) else 1 end; + def splits($p): if .type == "split" then + .direction as $d + | {path: $p, ratio: ((.first | cells($d)) / ((.first | cells($d)) + (.second | cells($d))))}, + (.first | splits($p + [false])), + (.second | splits($p + [true])) + else empty end; + .result.layout.root | splits([]) + | {id: "tmux-mode", method: "layout.set_split_ratio", + params: {tab_id: $tab, path: .path, ratio: .ratio}}' \ + | while IFS= read -r req; do + api "$req" >/dev/null + done |
