Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # requires:
- # set-option -ga update-environment ' TILE_NUM'
- SESSION="$(date +%Y-%m-%d-%H-%M-%S)"
- TILES="$1"
- re='^[0-9]+$'
- if [[ ! $TILES =~ $re ]]; then
- echo "usage: $0 <num> <cmd>"
- echo ' <num> number of tiles'
- echo ' <cmd> command to execute'
- echo
- echo 'Environment variable TILE_NUM will be set per call'
- exit 1
- fi
- shift
- CMD="$@"
- TILE_NUM='0' TILE_COUNT="$TILES" tmux new-session -s "$SESSION" -d "$CMD"
- for i in $(seq 1 $(($TILES - 1))); do
- tmux set-environment -t "$SESSION" 'TILE_NUM' "$i"
- tmux split-window -t "$SESSION" "$CMD"
- tmux select-layout -t "$SESSION" tile
- done
- tmux attach-session -t "$SESSION"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement