Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux: switch pane without losing current zoom state

Tags:

tmux

Is there a way to configure tmux to maintain its current zoomed/not zoomed state when switching panes? I can add a keybinding to automatically zoom after switching pane as follows:

bind-key -n C-l select-pane -t :.+\; resize-pane -Z

However this will zoom the new pane even if I was not previously zoomed. I would like to use the same keybinding to switch pane whether currently zoomed or not zoomed, and preserve the zoomed/not zoomed state.

like image 394
hollowcoda Avatar asked Sep 18 '25 14:09

hollowcoda


2 Answers

Depending on your version of tmux you can try this binding:

bind-key -n C-l if-shell -F "#{window_zoomed_flag}"  'select-pane -t :.+; resize-pane -Z'     'select-pane -t :.+'

This worked for me on tmux 2.2. if-shell -F does not run a shell command but just expands the window_zoomed_flag to 0 or 1, and runs the first or second command sequence.

like image 199
meuh Avatar answered Sep 23 '25 13:09

meuh


To just update the default <prefix>+; binding to keep zoom level when switching to the previous pane use this in your ~/.tmux.conf

# Keep zoom on last-pane switching
bind \; last-pane -Z

And run tmux source ~/.tmux.conf to re-read the config.

like image 29
Pylinux Avatar answered Sep 23 '25 13:09

Pylinux