7

I am trying to create a script that launches tmux with a specific pane layout and size. I am following the tutorial in the following link: https://leanpub.com/the-tao-of-tmux/read#pane-resizing

However when I try to use tmux split-window -p 75 it's more like a 40%/60% split. I've also tried tmux split-window -p 90 to see if I could get a bigger, and more evident, difference in size between the two panes but it doesn't change much.

These is the code that I am using:

#!/bin/sh tmux new -s abc -d tmux split-window -p 90 tmux attach -t abc 

I know how to create the layout that I want but my problem is getting the pane sizes that I need.

1 Answer 1

12

new-session
[…] With -d, the initial size comes from the global default-size option; -x and -y can be used to specify a different size.

(source)

The default default-size is 80x24. Before customizable default-size was introduced, new-session behaved as if it was 80x24.

What happens is split-window works fine. Then you attach and the layout is recalculated to the new width and height. My observation is tmux tends to keep the size of some pane(s) while resizing, it doesn't keep the relative proportions. I don't think you can change this behavior easily.

Tell new-session to use the size of your terminal:

#!/bin/sh tmux new-session -s abc -d -x "$(tput cols)" -y "$(tput lines)" tmux split-window -p 90 tmux attach -t abc 
2
  • 1
    Is possible to use "-" for sizes: tmux new-session -s abc -d -x - -y - Commented Dec 5, 2020 at 17:16
  • One minor note with this, the window may still be resized after attaching as the tmux status bar consumes a line, and causes a recalculation of height. If using bash (or compatible), you can do -y $(( $(tput lines) - 1 )). Commented Nov 10, 2024 at 23:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.