How to force a tmux window to be a given size

tmux

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?

Context

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)

Best Answer

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
Related Question