tmux: How to always resize all windows to maximum available size?

I am running tmux 3.0a, and when I connect with a smaller resolution terminal, also the bigger terminal gets resized to the smaller.

This is well known (although I don’t understand why they made this the default behaviour), and the solution is to c-b c-: :resize-window -A (tmux force resize window, https://stackoverflow.com/questions/7814612/is-there-any-way-to-redraw-tmux-window-when-switching-smaller-monitor-to-bigger/61764869#61764869). Unfortunately, this needs to be done in every pane/window.

While there is this option set-window-option -g aggressive-resize on, it doesn’t have any effect for me.

So: How to always resize all windows to maximum available size?

Asked By: DreamFlasher

||

Apperently, :resize-window -A needs to be done in every window, but when it’s done it’s persisting (when you disconnect and reconnect with a smaller terminal it remembers to resize aggressively).

Thus, include in your .bashrc the following command:

tmux resize-window -A

This sets aggressive resize for that specific window, whenever you open a new window.

It remains unclear why it actually works, see the discussion in the comments. The problem is that the documentation of tmux is unclear and there are three options that influence resizing.

Another way to achieve proper resizing seems to be (for tmux >=3.1):

set -g window-size latest
setw -g aggressive-resize on
Answered By: DreamFlasher

I have not yet figured out how to do this automatically.
But if you use xterm,
you can do this manually:

  1. detach from the tmux session,
  2. type resize into your terminal and run it,
  3. return to your session and the window should be resized.
Answered By: zyy
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.