Q:

tmux split-window using shell script

I am trying to write shell script for creating panes in tmux.
#!/bin/sh
tmux rename-window user
tmux new-session -d
tmux split-window -h
tmux selectp -t 1
tmux split-window -h
tmux select-layout even-horizontal
tmux selectp -t 2
tmux split-window -v

But when executing the above code doesn't produce desired output.
The picture indicates output produced when the code is executed:

Instead when all the commands are written in tmux it produces the desired output.
The picture indicates output produced when commands are manually typed:
 
How can the code be modified to produce the desired outcome?

A:

Try this, it looks like it does what you need (judging by the "Desired Output" image):
tmux split-window -h
tmux split-window -h
tmux select-layout even-horizontal
tmux split-window -v
tmux select-pane -t 0

You can also try persisting your layout using something like https://github.com/tmux-plugins/tmux-resurrect.

