Change Tmux background colour of zoomed pane
I'm using iTerm2 and Tmux.
I would like to change the background colour of a Tmux pane but only when zoomed. I know there is a window_is_zoomed flag and I am wondering if I can us this in a if-shell statement or somewhere else to get the desired effect.
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\""'