Last active
December 21, 2020 14:46
-
-
Save sunnyone/4d4a7c89f2b659278cc5794725f3eb6d to your computer and use it in GitHub Desktop.
Run multiple dev server
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 | |
PROJECT_ROOT=~/proj | |
COMMANDS=( | |
myserver "bundle exec rackup" | |
myclient "yarn dev" | |
) | |
COUNT=$((${#COMMANDS[@]} / 2)) | |
INDEX=0 | |
while [ $INDEX -lt $COUNT ] ; do | |
NAME=${COMMANDS[$(($INDEX * 2))]} | |
COMMAND=${COMMANDS[$(($INDEX * 2 + 1))]} | |
if [ "$INDEX" -eq 0 ] ; then | |
tmux new-session -d -c $PROJECT_ROOT/$NAME | |
else | |
tmux split-window -v -c $PROJECT_ROOT/$NAME -p $((100 - 100/($COUNT-$INDEX+1))) | |
fi | |
tmux send-keys "$COMMAND" C-m | |
INDEX=$((INDEX + 1)) | |
done | |
tmux attach-session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment