Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 95 lines (86 sloc) 2.27 KB
#!/bin/bash
export PATH=$PATH:/usr/local/bin
# Check if we're already in a tmux session
if [[ "$TMUX" != "" ]]; then
echo "Already running within tmux so bailing."
exit 0
fi
PS3="Please choose your session: "
sessions=($(tmux list-sessions -F "#S" 2>/dev/null) "New Session" "zsh")
incoming_message='What do you want to accomplish?: '
outgoing_message='What did you accomplish?: '
export DATABASE_URL=/Users/rsr/.tick/db/main.db
# A wrapper function around tick, lovingly named punch_clock.
# @param $1 tick sub-command
# @param $2 -n Name parameter for tick
# @param $3 -m Entry parameter for tick
#
function punch_clock {
if [[ -n $1 && ($(which tick) != "tick not found") ]]
then
if [[ $1 == 'list' ]]
then
tick -v $1 | grep "$2" | tail -n 25
elif [[ $3 != '' ]]
then
tick "$1" -n "$2" -m "$3"
else
tick "$1" -n "$2"
fi
fi
}
echo ">-< ------------------ >-<"
echo " Available Sessions"
echo ">-< ------------------ >-<"
echo
# Let's start by punching in.
#
select session in "${sessions[@]}"
do
case $session in
"New Session")
read -p "What are you working on? ( ex: abbr-name-with-dashes ): " new_session
read -p "$incoming_message" session_message
current_tux_session="$new_session"
punch_clock "start" "$new_session" "$incoming_message $session_message"
tmux new-session -s "$new_session"
break
;;
"zsh")
zsh --login
break
;;
*)
if [[ $session == "" ]]; then
echo "Please choose from the available sessions!"
continue
fi
read -p "$incoming_message" session_message
current_tux_session="$session"
punch_clock "start" $session "$incoming_message $session_message"
tmux attach-session -t $session
break
;;
esac
done
# Don't forget to punch out
#
if [[ "$?" == 0 && -n $current_tux_session ]];
then
read -p "$outgoing_message" session_message
punch_clock "stop" $current_tux_session "$outgoing_message $session_message"
echo
echo ">-< --------------------------- >-<"
echo " Here is a log of your time."
echo ">-< --------------------------- >-<"
punch_clock "list" $current_tux_session
fi
echo
echo ">-< -------------------- >-<"
echo " You look nice today."
echo ">-< -------------------- >-<"
# Wait for it
#
echo
read -rsp "Press any key to close your terminal..." -n1 key
exit 0