Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function tmux_web {
  4. SESSION_NAME=$1
  5. #echo "Create.."
  6. tmux -L $SESSION_NAME new -s $SESSION_NAME -n editor -d
  7. #echo "Creat first pane (editor).."
  8. tmux -L $SESSION_NAME send-keys -t $SESSION_NAME 'vim' C-m
  9. #echo "Run vim in first pane.."
  10. tmux -L $SESSION_NAME new-window -n console -t $SESSION_NAME
  11. #echo "Create second pane (console).."
  12. tmux -L $SESSION_NAME split-window -h -t $SESSION_NAME:2
  13. #echo "Split second pane.."
  14. tmux -L $SESSION_NAME new-window -n server -t $SESSION_NAME
  15. #echo "Create third pane (server)"
  16. tmux -L $SESSION_NAME new-window -n guard -t $SESSION_NAME
  17. #echo "Create fourth pane (guard)"
  18. tmux -L $SESSION_NAME new-window -n docker -t $SESSION_NAME
  19. #echo "Create fith pane (docker)"
  20. tmux -L $SESSION_NAME split-window -h -t $SESSION_NAME:5
  21. #echo "Split fifth pane (docker)"
  22. tmux -L $SESSION_NAME attach -t $SESSION_NAME
  23. #echo "Start tmux session $SESSION_NAME."
  24. }
  25.  
  26. #base new session name is current directory
  27. DIR_NAME=${PWD##*/}
  28.  
  29. echo "Trying to create new Tmux session with name '$DIR_NAME'."
  30. tmux has-session -t $DIR_NAME 2>/dev/null
  31. if [ $? -eq 1 ]
  32. then
  33. echo "Session not found. Create Session '$DIR_NAME'."
  34. tmux_web $DIR_NAME
  35. else
  36. #random string as new session suffix
  37. RAND_NUMB=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)
  38. echo "Session found. Create session with name '$DIR_NAME$RAND_NUMB'"
  39. tmux_web "$DIR_NAME$RAND_NUMB"
  40. fi
  41.  
  42. echo "Start tmux session $DIR_NAME."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement