gem install tmuxinator
# File: ~/.tmuxinator/project-name.yml
name: project-name
root: ~/Work/ProjectName
windows:
- App:
layout: tiled
panes:
- clear && cd App
- clear && ./boot-app App
- api:
layout: tiled
panes:
- clear && cd api
- clear && ./boot-app api
- sso:
layout: tiled
panes:
- clear && cd sso
- clear && ./boot-app sso
Checkout this simple config and this more advanced config.
Latest version can be found here in my dot-files.
# File: ~/bin/work
#!/bin/bash
display_usage() {
echo "This script is used to start tmuxinator project sessions."
echo -e "\nSupposing you have a session: ~/.tmuxinator/project-name.yml"
echo -e "\nExample usage:\n"
echo -e "work start project-name"
echo -e "work stop project-name \n"
}
if [ $# -ne 2 ]; then
display_usage
exit 1
fi
operation=$1
tmuxinator_config=$2
if [ $operation == "start" ]
then
tmux has-session -t $tmuxinator_config 2> /dev/null
if [ $? != 0 ]
then
mux start $tmuxinator_config
else
echo "tmux: $tmuxinator_config session is already running."
fi
fi
if [ $operation == "stop" ]
then
tmux has-session -t $tmuxinator_config 2> /dev/null
if [ $? == 0 ]
then
for i in `seq 1 10`;
do
tmux send-keys -t $tmuxinator_config:$i.1 C-c C-m
tmux send-keys -t $tmuxinator_config:$i.2 C-c C-m
tmux send-keys -t $tmuxinator_config:$i.3 C-c C-m
done
tmux kill-session -t $tmuxinator_config
else
echo "tmux: no $tmuxinator_config session found."
fi
fi
Start a project:
work start project-name
Stop a project:
work stop project-name
Cool! Thanks for sharing it.