Skip to content

Instantly share code, notes, and snippets.

@ASafaeirad
Created July 7, 2022 10:35
Show Gist options
  • Select an option

  • Save ASafaeirad/c3a2dcf0b8d8dbcd7eb2a9747f01e546 to your computer and use it in GitHub Desktop.

Select an option

Save ASafaeirad/c3a2dcf0b8d8dbcd7eb2a9747f01e546 to your computer and use it in GitHub Desktop.
TMUX automation for application development

TMUX automation for application development

#!/bin/bash
type tmux >/dev/null 2>&1 || {
echo "Sorry, but this script needs tmux"
exit 1
}
SESSION_NAME="codeit"
COMPOSE="docker-compose -f ./docker-compose.base.yml -f ./docker-compose.dev.yml"
scripts=("$COMPOSE up api" "$COMPOSE up postgres" "npm run start" "npm run studio")
tmux has-session -t $SESSION_NAME &>/dev/null
if [ $? != 0 ]; then
for script in "${scripts[@]}"; do
if [ -z $INITED ]; then
tmux new-session -s $SESSION_NAME -n $SESSION_NAME -d
INITED=1
else
tmux split-window -t $SESSION_NAME:$SESSION_NAME -h -p 33
fi
echo $script
tmux send-keys -t $SESSION_NAME:$SESSION_NAME "$script" C-m
done
tmux select-layout even-horizontal
fi
tmux attach-session -t $SESSION_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment