This tmux.sh script worked on my tmux 3.0a and after adding this: set -g pane-border-format "#{@mytitle}"
in my .tmux.conf (see why in comments bellow the scipt). You might have to add this: set -g pane-border-status bottom
in your .tmux.conf as well. With following command you name your session "ses", your window "win", pane 0 "p1" and pane 1 "p2":
tmux.sh ses win p1 p2
#!/bin/bash
session=$1
window=$2
pan1=$3
pan2=$4
#Get width and lenght size of terminal, this is needed if one wants to resize a detached session/window/pane
#with resize-pane command here
set -- $(stty size) #$1=rows, $2=columns
#start a new session in dettached mode with resizable panes
tmux new-session -s $session -n $window -d -x "$2" -y "$(($1 - 1))"
tmux send-keys -t $session 'echo "first command in 1st pane"' C-m
#rename pane 0 with value of $pan1
tmux set -p @mytitle "$pan1"
#split window vertically
tmux split-window -h
tmux send-keys -t $session 'echo "first command in 2nd pane"' C-m
tmux set -p @mytitle "$pan2"
#At the end, attach to the customized session
tmux attach -t $session
I had a lot of trouble to rename the panes because tmux select-pane -t $window.0 -T $pan1
should work but as stated here: https://stackoverflow.com/questions/60106672/prevent-tmuxs-pane-title-from-being-updated some updates of pane titles can be done by applications inside tmux. So I used the tricks given in the answer in the previous link (Nicholas Marriott gave also a solution for tmux version older than 3.0a)