Using tmux Zoom

.tmux.conf

Starting in tmux 1.8 a new feature called “zoom” (Ctrl+b z) was introduced. This allows you zoom into a pane, do work, and zoom back out.

Out of the box tmux should allow you to use Hotkey z (Ctrl+b z by default) right away, but something I found lacking was the ability to know if I was already zoomed in or not. Add the following to your .tmux.conf file to turn your active window red in the status bar:

setw -g window-status-current-format "#[fg=colour8]#[bg=white] #I #[bg=colour69]#[fg=white] #{?window_zoomed_flag,#[fg=red](,}#W#{?window_zoomed_flag,#[fg=red]),} "

If you are curious how I do all of my window status:

# -------------
# window status
# -------------
setw -g window-status-format "#[fg=black]#[bg=colour7] #I #[fg=black]#[bg=colour15] #W "
setw -g window-status-current-format "#[fg=colour8]#[bg=white] #I #[bg=colour69]#[fg=white] #{?window_zoomed_flag,#[fg=red](,}#W#{?window_zoomed_flag,#[fg=red]),} "
setw -g window-status-current-bg black
setw -g window-status-current-fg yellow
setw -g window-status-current-attr bold
setw -g window-status-bg black
setw -g window-status-fg blue
setw -g window-status-attr default

set -g status-left ''
set -g status-right-length 150
set -g status-right '#[fg=colour69] #(hostname -s)'


Demo

Before

img-paste-20170621165940812

Now select desired pane, Ctrl+b z

After

img-paste-2017062117024275

Then to zoom back out, Ctrl+b z

Avatar
Andrew Martin
Lead BI Infrastructure Architect

Related

comments powered by Disqus