You can provide your own bindings consisting of commands joined by \;
. For example in your ~/.tmux.conf
add
bind-key '"' split-window \; select-layout -n \; select-layout -p
This makes Ctrl-b " split the window, then change the layout to the next layout, then back to the previous layout. You would need to do this for other commands that add or remove windows.
If you want more automatic control, you can write a background tmux control mode process to listen to a real tmux process. It gets notifications of everything happening in the real tmux, and you could then send select-layout
commands whenever you see a notification of a new window, or a deleted window. I've not experimented much with this, but if you use 2 terminals and run a normal session in one
tmux new -s mysession
and in the other
tmux -C attach -t mysession
then when you split windows, add new ones, or close them in the normal tmux you will get lines like
%layout-change @2 91a8,80x23,0,0[80x11,0,0,5,80x11,0,12,7]
%window-add @3
%window-close @1
in the control tmux. When you see these you can write select-layout -n
in the control mode, and it affects the first. There's a python library to use this mechanism, which I have not looked at further.