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.

1 Answer 1


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.


  • 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\""'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.