Skip to content

Instantly share code, notes, and snippets.

@kiri-thornalley
Forked from bashbunni/.zshrc
Last active May 4, 2025 14:06
Show Gist options
  • Save kiri-thornalley/cdc82ca312edd809c5986ff5d9aea8d0 to your computer and use it in GitHub Desktop.
Save kiri-thornalley/cdc82ca312edd809c5986ff5d9aea8d0 to your computer and use it in GitHub Desktop.
CLI Pomodoro for Linux (modified for WSL2 on Windows 10)
# Requires https://github.com/caarlos0/timer to be installed.
# Requires Burnt Toast to be installed in Powershell. (https://github.com/Windos/BurntToast/tree/main)
# Modifcations from original gist (https://gist.github.com/bashbunni/3880e4194e3f800c4c494de286ebc1d7) by @bashbunni
# 1. spd-say removed and replaced with Burnt Toast for pop-up and audio notifications via Powershell.
# 2. Original pomodoro() function replaced with one that loops between work block and long/short break.
declare -A pomo_options
pomo_options["work"]="50"
pomo_options["break"]="10"
pomo_options["long_break"] = "25"
# Play alert using PowerShell/WSL or fallback
play_alert () {
if command -v powershell.exe &>/dev/null; then
powershell.exe -Command "New-BurntToastNotification -Text 'Pomodoro', 'Time is up!' -Sound 'Alarm8'"
# Sounds: Default,IM ,Mail,Reminder,SMS,Alarm,Alarm2,Alarm3,Alarm4,Alarm5,Alarm6,Alarm7,Alarm8,Alarm9,Alarm10,
# Call,Call2,Call3,Call4,Call5,Call6,Call7,Call8,Call9,Call10
else
echo -e "🔔 Time's up!" | lolcat
fi
}
pomodoro_loop () {
local cycles=${1:-4}
for ((i=1; i<=cycles; i++)); do
echo -e "\n🌱 Starting work session $i" | lolcat
timer "${pomo_options["work"]}m"
play_alert
if (( i % 4 == 0 )); then
echo -e "\n🌴 Long break (cycle $i)" | lolcat
timer "${pomo_options["long_break"]}m"
else
echo -e "\n🌸 Short break (cycle $i)" | lolcat
timer "${pomo_options["break"]}m"
fi
play_alert
done
echo -e "\n🎉 All $cycles Pomodoro cycles complete!" | lolcat
}
# Aliases
alias work="pomodoro_loop 1" # one work block - short break
alias loop="pomodoro_loop 4" # 3x work block - short break, followed by work block and long break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment