title: Create new pane from tmux command line
body: <p>I have a script that starts a tmux server and creates five windows in a session. Then it joins all the panes into one Window to form a five-window tiled pane:</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env sh
  
  tmux start-server
  
  # create a session with five windows
  tmux new-session -d -s MySession -n Shell1 -d "/usr/bin/env sh -c \"echo 'first shell'\"; /usr/bin/env sh -i"
  tmux new-window -t MySession:1 -n Shell2 "/usr/bin/env sh -c \"echo 'second shell'\"; /usr/bin/env sh -i"
  tmux new-window -t MySession:2 -n Shell3 "/usr/bin/env sh -c \"echo 'third shell'\"; /usr/bin/env sh -i"
  tmux new-window -t MySession:3 -n Shell4 "/usr/bin/env sh -c \"echo 'fourth shell'\"; /usr/bin/env sh -i"
  tmux new-window -t MySession:4 -n Shell5 "/usr/bin/env sh -c \"echo 'fifth shell'\"; /usr/bin/env sh -i"
  
  # merge all panes in one window
  tmux join-pane -t MySession:0 -s 1
  tmux join-pane -t MySession:0 -s 2
  tmux join-pane -t MySession:0 -s 3
  tmux join-pane -t MySession:0 -s 4
  
  # change layout to tiled
  tmux select-layout -t MySession:0 tiled
  
  tmux attach -tMySession
  </code></pre>
  
  <p>Is there a way to optimize it by directly creating five panes in first window (instead of first creating individual windows and then merge)?</p>
  
  <hr>
  
  <p><strong>Solution</strong></p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env sh
  
  tmux start-server
  
  # create a session with five panes
  tmux new-session -d -s MySession -n Shell1 -d "/usr/bin/env sh -c \"echo 'first shell'\"; /usr/bin/env sh -i"
  tmux split-window -t MySession:0 "/usr/bin/env sh -c \"echo 'second shell'\"; /usr/bin/env sh -i"
  tmux split-window -t MySession:0 "/usr/bin/env sh -c \"echo 'third shell'\"; /usr/bin/env sh -i"
  tmux split-window -t MySession:0 "/usr/bin/env sh -c \"echo 'fourth shell'\"; /usr/bin/env sh -i"
  tmux split-window -t MySession:0 "/usr/bin/env sh -c \"echo 'fifth shell'\"; /usr/bin/env sh -i"
  
  # change layout to tiled
  tmux select-layout -t MySession:0 tiled
  
  tmux attach -tMySession
  </code></pre>