tmux-zoomをつかっていたがrotate-windowに耐性がないことに気づいてしまったのと、pane_indexではなくてpane_idをつかえばよさそうというアイデアがうかんだのでスクリプトを書いてみた。
pane_indexとpane_idの関係はこんなかんじ↓になっている。tmux rotate-windowを実行するとpane_indexは上から順番に0,1,2のままだがpane_idは上に1つずれる。
window_index=0
+---------------+
| pane_index=0 |
| pane_id=%0 |
| |
| |
+---------------+
| pane_index=1 |
| pane_id=%1 |
| (active) |
| |
+---------------+
| pane_index=2 |
| pane_id=%2 |
| |
| |
+---------------+
|
| tmxu rotate_window
V
window_index=0
+---------------+
| pane_index=0 |
| pane_id=%1 |
| (active) |
| |
+---------------+
| pane_index=1 |
| pane_id=%2 |
| |
| |
+---------------+
| pane_index=2 |
| pane_id=%0 |
| |
| |
+---------------+
この様子は tmux list-panes -a をみてるとわかる。
スクリプトを書いてて気づいたのはpaneはtty(とプロセス)に紐付いているのであってwindowの矩形領域のことではない。swap-paneでいれかわるのは矩形領域とttyのつながりである。pane_indexが矩形領域の識別子で、pane_idがtty/processの識別子ということのようだ。
window_index=0 window_index=1
+---------------+ +---------------+
| pane_index=0 | | pane_index=0 |
| pane_id=%0 | | pane_id=%3 |
| | | |
| | | |
+---------------+ | |
| pane_index=1 | | |
| pane_id=%1 | | |
| | | |
| | | |
+---------------+ | |
| pane_index=2 | | |
| pane_id=%2 | | |
| | | |
| | | |
+---------------+ +---------------+
|
| swap-pane -s %0 -t %3
|
V
window_index=0 window_index=1
+---------------+ +---------------+
| pane_index=0 | | pane_index=0 |
| pane_id=%3 | | pane_id=%0 |
| | | |
| | | |
+---------------+ | |
| pane_index=1 | | |
| pane_id=%1 | | |
| | | |
| | | |
+---------------+ | |
| pane_index=2 | | |
| pane_id=%2 | | |
| | | |
| | | |
+---------------+ +---------------+















