Whether you’re juggling multiple windows and panes across nested tmux sessions, having a single, ergonomic shortcut to switch and zoom panes can save you valuable time. This snippet extends your outer tmux configuration to bind <prefix> g
for a seamless, two-step pane selection: un-zoom the current pane, display a long-lasting pane number overlay, and automatically zoom the pane you choose—all in one intuitive command.
Use this snippet in your ~/.ubertmux
to bind <prefix> g
so it:
- Works whether the current pane is zoomed or not
- Displays pane numbers overlay for up to 600 seconds (10 minutes)
- Allows you to select any pane (including the same one) and zoom it automatically
# ~/.ubertmux
# Unbind existing 'g' binding
unbind-key g
# Bind '<prefix> g' robustly
bind-key g \
if-shell -F '#{window_zoomed_flag}' 'resize-pane -Z' '' \; \
display-panes -d 600000 "select-pane -t '%%'; resize-pane -Z"
-
Conditional un-zoom
- The
if-shell -F '#{window_zoomed_flag}' 'resize-pane -Z' ''
checks if the current pane is zoomed (window_zoomed_flag
= 1). - If zoomed, it runs
resize-pane -Z
to un-zoom; otherwise, it does nothing.
- The
-
Display pane numbers
display-panes -d 600000 ...
shows a numbered overlay for 600,000 milliseconds (600s).- The command following the duration is a template: when you press a pane number, tmux substitutes
%%
with the pane ID and runs the commands.
-
Select and zoom
- The template
"select-pane -t '%%'; resize-pane -Z"
switches to the chosen pane and immediately zooms it, even if it's the pane you were already in.
- The template
Co-created with ChatGPT o4-mini-high: