Created
June 30, 2015 10:33
-
-
Save whnr/d44df1f8909a7a350220 to your computer and use it in GitHub Desktop.
Terminal Pomodoro Timer (OSX) Bash Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Small Pomodoro Timer | |
# Based on https://en.wikipedia.org/wiki/Pomodoro_Technique | |
# Requires terminal-notifier for OSX | |
# Author: [email protected] | |
# All times in minutes | |
work=30; | |
break_small=5; | |
break_big=20; | |
# Number of work periods | |
work_periods=3; | |
let duration="$work_periods*$work+($work_periods-1)*$break_small+$break_big"; | |
echo " _ "; | |
echo " | | "; | |
echo " _ __ ___ _ __ ___ ___ __| | ___ _ __ ___ "; | |
echo " | '_ \ / _ \| '_ \` _ \ / _ \ / _\` |/ _ \| '__/ _ \ "; | |
echo " | |_) | (_) | | | | | | (_) | (_| | (_) | | | (_) |"; | |
echo " | .__/ \___/|_| |_| |_|\___/ \__,_|\___/|_| \___/ "; | |
echo " | | "; | |
echo " |_| "; | |
echo ""; | |
echo " Work shedule for the next $duration minutes:"; | |
echo " - $work_periods work periods of $work minutes each"; | |
echo " - Small break of $break_small minutes in between"; | |
echo " - And a big $break_big minute break at the end"; | |
echo ""; | |
# Verbose commandline countdown with with label | |
# timecount $time_in_minutes $name_of_the_countdown | |
timecount(){ | |
min=$1 | |
name=$2 | |
sec=0 | |
while [ $min -ge 0 ]; do | |
while [ $sec -ge 0 ]; do | |
echo -ne " $name for $min min $sec sec\033[0K\r" | |
sec=$((sec-1)) | |
sleep 1 | |
done | |
sec=59 | |
min=$((min-1)) | |
done | |
} | |
# The pomodoro procedure | |
while [ $work_periods -ge 1 ]; do | |
timecount $work "Work" | |
if [ $work_periods -ge 2 ]; then | |
terminal-notifier -remove "pomodoro" > /dev/null | |
terminal-notifier -group "pomodoro" -title "Pomodoro break" -message "Work ist done! A $break_small min break starts" | |
timecount $break_small "Small Break" | |
terminal-notifier -remove "pomodoro" > /dev/null | |
terminal-notifier -group "pomodoro" -title "Pomodoro break over" -message "The small break is over. Start the next in the terminal!" | |
echo -ne " Press any key for the next pomodoro!\033[0K\r"; | |
read -n 1 -s | |
else | |
terminal-notifier -remove "pomodoro" > /dev/null | |
terminal-notifier -group "pomodoro" -title "Pomodoro break" -message "Work ist done! A large $break_big min break starts" | |
timecount $break_big "Large Break" | |
terminal-notifier -remove "pomodoro" > /dev/null | |
terminal-notifier -group "pomodoro" -title "Pomodoro Session is over" -message "This Session is over. Ready for a new one? Run the script!" | |
echo " You are done! Let's start another session!"; | |
fi | |
work_periods=$((work_periods-1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment