Skip to content

Instantly share code, notes, and snippets.

@CGA1123
Created June 27, 2018 09:29
Show Gist options
  • Save CGA1123/ec0a17ac19cbf320e71ba3a271b1c736 to your computer and use it in GitHub Desktop.
Save CGA1123/ec0a17ac19cbf320e71ba3a271b1c736 to your computer and use it in GitHub Desktop.
Script for a better morning
#!/bin/bash
set -u
# Do things...
tmux start-server
# Open tmux session for a project
function tmux_setup () {
local PROJECT=${1}
local PROJECT_DIR=${MORNING_PROJECTS_HOME}/${PROJECT}
cd ${PROJECT_DIR}
tmux new-session -s ${PROJECT} -d -n 'server'
tmux new-window -t ${PROJECT}:1 -n log
tmux new-window -t ${PROJECT}:2 -n shell
tmux send-keys -t ${PROJECT}:0 'foreman start -f Procfile.dev' 'C-m'
tmux send-keys -t ${PROJECT}:1 'tail -f log/development.log' 'C-m'
printf "%-35s -- %s\n" "${PROJECT} is ready" "tmux a -t ${PROJECT}"
}
echo "Good Morning!"
echo "Setting up projects..."
echo "Projects: ${MORNING_PROJECTS}"
echo "Project Home: ${MORNING_PROJECTS_HOME}"
for MORNING_PROJECT in ${MORNING_PROJECTS[@]}; do
tmux_setup ${MORNING_PROJECT} &
done
wait
echo "Setup done!"
echo "Have a good day"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment