Take this one-liner (split into multiple lines for readability) as an example:
tmux set-hook -g after-resize-pane \
'if "[ #{window_zoomed_flag} -eq 1 ]"
"run \"tmux select-pane -P bg=red\""
"run \"tmux select-pane -P bg=black\""
'
Run it in a shell within tmux
and zoom any pane to test the solution.
Notes:
- It's pure
tmux
solution, it doesn't depend on iTerm2.
- There are three levels of quoting (single-quotes, double-quotes, escaped double-quotes). While adjusting the command to your needs don't mix them up.
-g
means the hook is global; without -g
it's a session hook.
- Unset the hook with
tmux set-hook -gu after-resize-pane
.
To make the solution permanent, add this line to ~/.tmux.conf
(or /etc/tmux.conf
):
set-hook -g after-resize-pane 'if "[ #{window_zoomed_flag} -eq 1 ]" "run \"tmux select-pane -P bg=red\"" "run \"tmux select-pane -P bg=black\""'