brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: setw -g aggressive-resize on sizes tmux windows per current window

Tmux
~/tips/tip-tmux-aggressive-resize

setw -g aggressive-resize on

Sizes a tmux window to the sessions that have it as current window.

When I attach to one tmux server from a big screen and from a small one, tmux has to pick a window size, and one of the two screens gets a poor fit. One option changes how that choice is made.

The window option aggressive-resize changes what tmux looks at when it sizes a window. According to the manual, tmux then resizes the window to the size of the smallest or largest session (see window-size) for which it is the current window, instead of the session it is attached to.

setw -g aggressive-resize on

Say my big monitor shows window 1 and the small screen shows window 2. Window 1 can then use the whole big screen. The manual adds that a window may resize when the current window changes in another session.

The size rule itself comes from window-size, which takes largest, smallest, manual or latest. With latest, tmux uses the size of the client that had the most recent activity:

set -g window-size latest

The manual calls aggressive-resize good for full-screen programs that support SIGWINCH and poor for interactive programs such as shells. A shell window that resizes whenever you change window elsewhere gets confusing, so I would try window-size latest first and reach for aggressive-resize only if that is not enough.

Further reading: tmux manual

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link