#!/usr/bin/env bash
if [ "$1" == "" ];
then
echo "Usage1: `basename $0` [SESSION_NAME] [PROJECT]"
echo " Create a new session with git/sass/tpl windows and start watch"
echo "Usage2: `basename $0` [SESSION_NAME]"
echo " Attach the exist session and detach other clients"
echo "---"
echo "<Alive session>"
tmux ls
exit 0
fi
SESSION_NAME=$1
PROJECT=$2
tmux has-session -t ${SESSION_NAME}
if [ $? != 0 ];
then
if [ "${PROJECT}" == "" ];
then
echo "Syntax error: Missing param2 [PROJECT]"
exit 0
fi
cd ${PROJECT}
tmux new-session -d -s ${SESSION_NAME}
tmux rename-window -t ${SESSION_NAME}:0 "git"
tmux new-window -t ${SESSION_NAME}:1 -n sass
tmux new-window -t ${SESSION_NAME}:2 -n tpl
tmux send-keys -t ${SESSION_NAME}:0 './oconf compile' C-m
tmux send-keys -t ${SESSION_NAME}:1 './oconf watch sass' C-m
tmux send-keys -t ${SESSION_NAME}:2 './oconf watch tpl' C-m
tmux select-window -t ${SESSION_NAME}:0
fi
tmux a -dt ${SESSION_NAME}