Created
February 10, 2019 15:54
-
-
Save subeshb1/d70b9b389892808ec0ef160331ab0652 to your computer and use it in GitHub Desktop.
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 | |
SESSION_NAME="FLOW" | |
# Creating SESSION | |
tmux new -d -s $SESSION_NAME | |
tmux set -g remain-on-exit on | |
# Different Apps as Windows | |
WINDOWS=("DATABASES" "CP" "WP" "DISPATCHER" "GOLDFISH" "AUTOFILL") | |
# Starting PATH for each WINDOW | |
PATHS=("~" "~/Platforms/clientplatform" "~/Platforms/workerplatform" "~/Platforms/dispatcher" "~/Platforms/goldfish" "~/Platforms/autofill") | |
DATABASES=("mongod" "redis-server" "mysql.server start" "memcached -vv" ) | |
CP=("rails s -p 3000" "sidekiq") | |
# # Commands for each windows | |
# declare -A COMMANDS | |
# COMMANDS["DATABASES"]=("redis-server" "memcached -vv" "mysql.server start" "mongod") | |
# COMMANDS["CP"]=("rails s -p 3000" "") | |
function start_app() { | |
local TWINDOW_NAME=${1} | |
local TWINDOW_PATH="$2" | |
declare -i COMMAND_LENGTH=$(eval echo \${\#${TWINDOW_NAME}[@]}) | |
echo "Creating Window -> $SESSION_NAME:$3($TWINDOW_NAME) at PATH=$TWINDOW_PATH" | |
tmux new-window -t $SESSION_NAME:$3 -n "${WINDOWS[$i]}" "cd ${PATHS[$i]};zsh" | |
printf " Creating Panes: $COMMAND_LENGTH\n" | |
for ((i=0; i < ${COMMAND_LENGTH}; i++ )); do | |
tmux split-window -h -t "$SESSION_NAME:$3.$(($i+1))" "$(eval echo \${${TWINDOW_NAME}[$i]});zsh" | |
done | |
} | |
for i in $(seq 0 $((${#WINDOWS[@]} - 1))); do | |
start_app "${WINDOWS[$i]}" "${PATHS[$i]}" $(($i+2)) | |
done | |
echo "Show Session? [y/n]" | |
read -n 1 data | |
if [[ $data == "y" ]]; then | |
echo $data | |
tmux a -t $SESSION_NAME | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment