Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function tmux_web {
- SESSION_NAME=$1
- #echo "Create.."
- tmux -L $SESSION_NAME new -s $SESSION_NAME -n editor -d
- #echo "Creat first pane (editor).."
- tmux -L $SESSION_NAME send-keys -t $SESSION_NAME 'vim' C-m
- #echo "Run vim in first pane.."
- tmux -L $SESSION_NAME new-window -n console -t $SESSION_NAME
- #echo "Create second pane (console).."
- tmux -L $SESSION_NAME split-window -h -t $SESSION_NAME:2
- #echo "Split second pane.."
- tmux -L $SESSION_NAME new-window -n server -t $SESSION_NAME
- #echo "Create third pane (server)"
- tmux -L $SESSION_NAME new-window -n guard -t $SESSION_NAME
- #echo "Create fourth pane (guard)"
- tmux -L $SESSION_NAME new-window -n docker -t $SESSION_NAME
- #echo "Create fith pane (docker)"
- tmux -L $SESSION_NAME split-window -h -t $SESSION_NAME:5
- #echo "Split fifth pane (docker)"
- tmux -L $SESSION_NAME attach -t $SESSION_NAME
- #echo "Start tmux session $SESSION_NAME."
- }
- #base new session name is current directory
- DIR_NAME=${PWD##*/}
- echo "Trying to create new Tmux session with name '$DIR_NAME'."
- tmux has-session -t $DIR_NAME 2>/dev/null
- if [ $? -eq 1 ]
- then
- echo "Session not found. Create Session '$DIR_NAME'."
- tmux_web $DIR_NAME
- else
- #random string as new session suffix
- RAND_NUMB=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)
- echo "Session found. Create session with name '$DIR_NAME$RAND_NUMB'"
- tmux_web "$DIR_NAME$RAND_NUMB"
- fi
- echo "Start tmux session $DIR_NAME."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement