Im trying to script up a nice tmux config but I'm having some problems with how to target panes for splitting and selections. I want to create the following layout where the Vim pane is selected as default. I also want to create a second window as is seen in the script but this is not the problem.
---------------------
|        VIM        |
|-------------------|
|         |         |
|  ZSH    | ghci    |
|-------------------|
session=$1
tmux has-session -t $session
if [ $? != 0 ]
then
     tmux new-session -s $session -n editor -d
     tmux send-keys -t $session 'vim' C-m
     tmux split-window -v -p 20 -t $session
     tmux split-window -h -t $session:2
     tmux new-window -n console -t $session
     tmux select-window -t $session.1
     #tmux select-pane -t $session:1.1
     tmux attach -t $session
else
     echo 'SESSION ALREADY EXISTS'
fi
So my questions are:
How how can I target a specific pane to split horizontally so that I can create the ZSH/ghci split? How do I target a specific pane to execute a command such as ghci?
                        
The
-toption tosplit-windowcan take an argument of the form<sessionname>:<windownumber>.<panenumber>which you can use to specify exactly which pane should be split.new-sessioncan take an argument specifying which command to run in the initial window, which removes the need forsend-keys. A similar argument is used withsplit-windowto specify what command to run in the new pane if not the default shell.Of course, the pane closes when its command ends, so you want to be able to close
vim/ghciwithout destroying the pane, stick withsend-keys(whose-targument can take the same pane identifier used withnew-sessionandsplit-window), or look at theremain-on-exitoption.