tmux: zoom panes

Last update:

Although I’ve been using tmux for some years now, I only fairly recently discovered pane zooming. It’s a shortcut that toggles between maximizing the current pane (e.g. filling the entire terminal window) and restoring the previous layout.

tmux pane zoom

By default that shortcut is <prefix> z. In vanilla tmux <prefix> is Ctrl-b, therefore the shortcut is Ctrl-b z. Most people bind the prefix shortcut to Ctrl-a, presumably to be compatible with screen and because it’s easier to type, especially if caps-lock is remapped to control. In that latter case the shortcut is consequently Ctrl-a z.

To ease zooming even further, let’s consider the following piece of tmux config. It binds pane zooming to simply Ctrl-Space. Wow, instant win!

# Ctrl-Space to zoom current pane
bind-key -n C-Space resize-pane -Z

Decomposing the config line yields:

  • bind-key: define a key binding, aka a shortcut
  • -n: without the prefix, aka in the root table
  • C-Space: when pressing Ctrl-Space
  • resize-pane -Z: do zoom the current pane

Now that’s already very useful. But what would be even better? Highlighting zoomed tmux windows in the status line. Here you go:

setw -g window-status-current-format '#{?window_zoomed_flag,#[fg=yellow],}#F#I [#W] '

Resources:


See all posts in the archive.

Comments

Comments were disabled in March 2022. Since this page was created earlier, there may have been previous comments which are now inaccessible. Sorry.