Created
June 6, 2013 16:14
-
-
Save ryuone/5722779 to your computer and use it in GitHub Desktop.
Create Tabs and Panes for tmux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SESSION_NAME="TmuxSession" | |
TMUX_TABS=2 | |
TMUX_PANES=16 | |
tmux start-server | |
if ! $(tmux has-session -t "${SESSION_NAME}"); then | |
cd ~/ | |
env TMUX= tmux start-server \; set-option -g base-index 1 \; new-session -d -s "${SESSION_NAME}" -n 'shell1' | |
tmux set-option -t "${SESSION_NAME}" default-path ~/ | |
for (( i = 2; i <= TMUX_TABS; i++ )) | |
do | |
tmux new-window -t "${SESSION_NAME}":${i} -n "shell${i}" | |
done | |
for (( i = 1; i <= TMUX_TABS; i++ )) | |
do | |
tmux send-keys -t "${SESSION_NAME}":${i} "echo 1" C-m | |
for (( j = 2; j <= TMUX_PANES; j++ )) | |
do | |
tmux splitw -t "${SESSION_NAME}":${i} | |
tmux send-keys -t "${SESSION_NAME}":${i} "echo ${j}" C-m | |
tmux select-layout -t "${SESSION_NAME}":${i} 'tiled' | |
done | |
done | |
tmux select-window -t "${SESSION_NAME}":1 | |
fi | |
if [ -z $TMUX ]; then | |
tmux -u attach-session -t "${SESSION_NAME}" | |
else | |
tmux -u switch-client -t "${SESSION_NAME}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment