I want to force the windows in my tmux session to be a particular size, regardless of the the size of my terminal. How can I do this?


I am trying to record a tmux in asciinema as described here https://github.com/asciinema/asciinema/wiki/Recording-tmux-session (run asciinema on a tmux attach command). However the display is too big, I want to force the size of the tmux window.

Things that I have tried

I have a successful work around where I use a second view of the tmux session in mate-terminal -e 70x20 to force the window size... but this seems like a hack.

Trying to force the session size with -x

tmux new-session -x $X -y $Y -d

These options seem to be ignored (I've tried fiddling with the aggressive resize setting)

3 Answers 3


You probably need to have at least 3 panes open to occupy the unwanted areas. Try something like

tmux new-session \; split-window -h \; split-window -v \; resize-pane -x 70 -y 20
  • ... because tmux does not allow resizing of the window, only panes.
    – Kusalananda
    Apr 15, 2017 at 9:30
  • 1
    This is one of the approaches I was considering. For my use case it's problematic because I creating new panes and new windows in the animation. Window resizing functionality is present internally within tmux (because windows get resized when new clients connect) I guess it's just not exposed.
    – Att Righ
    Apr 15, 2017 at 13:49

This should do what you want:

tmux new-session \; setw force-width 80 \; setw force-height 24 \; attach

or with $X and $Y, of course.


This is a bug in tmux, and has been fixed in the development version. The latest released version at this time is 3.2a, which does not have the fix.

It only appears to ignore the -x and -y options for a new detached session. The documentation says that these values will override the default-size settings for new windows, which suggested creating a new session, setting the default size, launching a new window, and then killing the initial window. That works. However, you can use the -x and -y options to override the default-size setting to avoid needing to adjust it, but you still have to create a new window. The problem is that the -x and -y modify the default-size for the session after the initial window has already been created.

tmux new-session -d -x $X -y $Y \; new-window ${MY_COMMAND} \; kill-window -t 0

So that will create a new session with the default size you want, then create a new window with the desired size running ${MY_COMMAND}, and finally kill the other window. This should work for running a command in a virtual terminal of whatever dimensions are required.

You must log in to answer this question.

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