DEV Community

Juan Burgos
Juan Burgos

Posted on • Edited on

Micro-Post: Tracking TMUX pane zoom-in status

Something that I used to struggle with is remembering whether or not I'm currently zoomed into a particular pane on any particular TMUX window.

The following is what I implemented to resolve this problem for myself, and I thought this may be interesting to others.

In my tmux.conf file, I added the following zoom binding:

# automatically reload zoomed-in status
bind z {
  resize-pane -Z
  if-shell "tmux list-panes -F '#{?window_zoomed_flag,yes,no}' | grep yes" {
    set -g status-left "[#S | ZOOMED-IN ] " ## Print session label in the left side of the status bar
  } {
    set -g status-left "[#S] " ## Print session label in the left side of the status bar
  }
}
...
...
# simple pane rename binding
bind R command-prompt -p "(rename-pane)" -I "#T" { select-pane -T "%%" }
...
...
# setting the pane status bar how I like it
set -g pane-border-style fg=yellow
set -g pane-active-border-style "bg=default fg=yellow"
set -g pane-border-status top
set -g pane-border-format "[ ###P | #T | CMD: `#{pane_current_command}` ]"
Enter fullscreen mode Exit fullscreen mode

The result is that when I'm "zoomed out" I see, the following in my window status bar:

[SESSION_NAME] (0: WINDOW_NAME)
──[ #0 | PANE_NAME | CMD: `zsh`]───────────
Enter fullscreen mode Exit fullscreen mode

When I zoom into pane #0, my window status bar shows the following:

[SESSION_NAME | ZOOMED-IN ] (0: WINDOW_NAME)
──[ #0 | PANE_NAME | CMD: `zsh`]───────────
Enter fullscreen mode Exit fullscreen mode

Zooming out will automatically return the window status bar back to what it originally was:

[SESSION_NAME] (0: WINDOW_NAME)
──[ #0 | PANE_NAME | CMD: `zsh`]───────────
Enter fullscreen mode Exit fullscreen mode

I just so happened to prefer seeing the "ZOOMED-IN" statement at the very top of my TMUX session's status bar since it catches my attention more easily.

I also threw in here a simple binding for quickly changing pane titles since it's also useful.

Hope others find this info useful :-)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (1)

Collapse
 
jlburgos profile image
Juan Burgos

Updated this page after realizing that the if-shell command I previously provided only worked on my Mac. New command works on both Mac and Linux.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more