0

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?

2 Answers 2

3

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
17
  • 2
    Just set -g window-size largest or smallest whichever you prefer, if you do resize-window -A you end up with it set to manual for that window and you will need to do it again every time you resize the terminal. Jan 19, 2021 at 10:13
  • oh wow! I am still testing it, but this looks even better – You should make this an answer instead of a comment! Jan 19, 2021 at 11:53
  • Sorry, I was too quick. set -g window-size largest sets the window-size to the largest window, and thus on the smaller one you only see half the content. So tmux resize-window -A is still the only way to have the right window size for all clients. Jan 19, 2021 at 12:01
  • 1
    Despite not being in the man page of 3.2, latest still seems to be a valid option. The combination of aggressive-resize on and window-size latest works also very well for me. Feb 23, 2021 at 20:01
  • 1
    aggressive-resize predates the other stuff here and the intent is that when tmux is automatically sizing a window, it only checks the size of a session the window is linked to if the window is the current window. It is aggressive because this meant that if you have the same window linked to multiple sessions, it will be resized more often with the option on than with it off (because with it on it could be resized when it becomes the current window). In practice I am not sure aggressive-resize matters anymore and we should probably just make having it on the default. Feb 28, 2021 at 15:05
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .