Skip to content

Instantly share code, notes, and snippets.

@sunnyone
Last active December 21, 2020 14:46
Show Gist options
  • Save sunnyone/4d4a7c89f2b659278cc5794725f3eb6d to your computer and use it in GitHub Desktop.
Save sunnyone/4d4a7c89f2b659278cc5794725f3eb6d to your computer and use it in GitHub Desktop.
Run multiple dev server
#!/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