Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # requires:
  4. # set-option -ga update-environment ' TILE_NUM'
  5.  
  6. SESSION="$(date +%Y-%m-%d-%H-%M-%S)"
  7.  
  8. TILES="$1"
  9. re='^[0-9]+$'
  10. if [[ ! $TILES =~ $re ]]; then
  11. echo "usage: $0 <num> <cmd>"
  12. echo ' <num> number of tiles'
  13. echo ' <cmd> command to execute'
  14. echo
  15. echo 'Environment variable TILE_NUM will be set per call'
  16. exit 1
  17. fi
  18.  
  19. shift
  20. CMD="$@"
  21.  
  22. TILE_NUM='0' TILE_COUNT="$TILES" tmux new-session -s "$SESSION" -d "$CMD"
  23.  
  24. for i in $(seq 1 $(($TILES - 1))); do
  25. tmux set-environment -t "$SESSION" 'TILE_NUM' "$i"
  26. tmux split-window -t "$SESSION" "$CMD"
  27. tmux select-layout -t "$SESSION" tile
  28. done
  29.  
  30. tmux attach-session -t "$SESSION"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement