I have a tmux session created in detach mode and I ran a series tmux commands in a script to ceate panes and resize panes but when trying to attach to the session, panes are in different size, if in that, I run the same commands to resize panes in the script, panes' size resize correctly.

Why in detach mode and resize panes result incorrectly?

EDIT: I guess tmux resized panes when client attach.

1 Answer 1


tmux changes size of panes depending on size of terminal (the smallest width and the smallest height of all clients). When is tmux attached to terminal with same size as before, the panes have same size. When it is attached to terminal with different size, it is changed proportionally. (If you have two panes of width 20 and 60 in terminal with width 80 and the attached session uses terminal with width 40, new width of panes will be 10 and 30.)

If you want to keep the size, attach it to terminal with same size.

When are multiple clients attached, it is also resized: (some parts are removed from image)

multiple tmux clients

  • 1
    I create in detach mode and attach latter with the same client, or it's just the first time client to connect to tmux session. Commented Oct 15, 2018 at 0:09
  • It is resized every time the client connects. When connected, tmux resizes the session to size that can all clients show. When the size is different, panes are resized proportionally. When is the size same, it is not resized.
    – jiwopene
    Commented Oct 15, 2018 at 6:05
  • 1
    I created session in detach mode and connect to the specific window then split -h and -v to setup layout then attach to session for the first time, the size of panes are not setup correctly, how to prevent it? There's must be default for panes' size when not connected to a client? Commented Oct 15, 2018 at 6:16

You must log in to answer this question.

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