33

I'm using a ‘session group’, to keep multiple OS-level, window-managed terminal windows open to different tmux ‘windows’ (so they share a default working-directory, tmux settings, etceteras.) Those Terminal windows are different sizes.

Normally, from a larger Terminal, I can do the following to start a new command:

:new-window vim

However, if I ever switch to a different pane with that new, larger Terminal window, I am foreverafter stuck with this, when I switch back:

I have to kill the entire session, create an entirely new session, and link it to the session-group again, using tmux new-session -t <blah>, to restore the full terminal-width.

Is there any other way to restore / change / set the ‘available width’ of a session (or window, idk)?

4
  • have you enabled the aggressive-resize option? also, if two different sized clients are attached at the same time, the larger screen'd client will be forced to the smaller screen'd client. try detaching others when attaching with a new client.
    – Daniel
    Feb 20, 2015 at 18:56
  • 1
    Problem is, they're attached to different sessions. That's exactly what I'm trying to circumvent; the problem isn't at attach-time, it's only when I switch windows. Feb 20, 2015 at 18:57
  • Also, set aggressive-resize solves it! Add that as a real answer, and I'll give you an accept. (= Feb 20, 2015 at 18:58
  • I thought that might help, glad it worked.
    – Daniel
    Feb 20, 2015 at 19:08

4 Answers 4

30

Perhaps enabling the aggressive-resize option will help:

set-window-option -g aggressive-resize

A good overview of tmux options is given here.

3
  • 1
    FYI this doesn't work with iTerm2 as it states it's incompatible with this option. Aug 25, 2021 at 20:08
  • What could be used in iTerm2 to overcome this?
    – alper
    Mar 31 at 17:09
  • tmux -CC attach -d works for iTerm2.
    – srgsanky
    Apr 26 at 4:34
15

When attach screen you may use detach mode

tmux attach -d with will resize screen after disconnect other clients from the sessions (and someone who used small screen)

Or you can interactively detach by pressing Ctrl-B-Shift-D

1
2

Starting with tmux 3.1, the default option for window-size is latest. So all you need to do is upgrade.

1

there is also:
tmux resize-window -A # to resize to the largest session or
tmux resize-window -a # to the smallest session
(or specific geometry see man tmux |less +/resize-window)

(of course alternatively use <prefix>:resize-window -a)

You must log in to answer this question.

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