Skip to content

Instantly share code, notes, and snippets.

@brianbert
Forked from bashbunni/.zshrc
Last active March 3, 2023 01:40
Show Gist options
  • Save brianbert/09085ff9f00f1c5412afd8f497386e17 to your computer and use it in GitHub Desktop.
Save brianbert/09085ff9f00f1c5412afd8f497386e17 to your computer and use it in GitHub Desktop.
CLI Pomodoro for Linux (with loop, notifications and terminal commands!)
declare -A pomo_options
pomo_options["work"]="0.5"
pomo_options["break"]="0.5"
pomodoro() {
val=$1
echo $val | lolcat
timer ${pomo_options["$val"]}m
spd-say "'$val' session done"
notify-send --app-name=Pomodoro🍅 "'$val' session done 🍅"
}
start_pomodoro() {
# Number of times to repeat the loop, default is 2
if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then
num_loops=$1
else
# Default Loops
num_loops=2
fi
for i in $(seq 1 $num_loops); do
pomodoro "work"
pomodoro "break"
done
}
change_pomo() {
if [ -n "$1" ] && [ -n "$2" ]; then
pomo_options["$1"]="$2"
echo "The $1 time has been changed to $2 minutes"
else
echo "Please provide valid parameters: change_pomo [work/break] [time_in_minutes]"
fi
}
alias doro=start_pomodoro
alias wo="pomodoro 'work'"
alias br="pomodoro 'break'"
alias cp=change_pomo
@brianbert
Copy link
Author

brianbert commented Jan 23, 2023

Commands (Change the Ñ for the number you want):

Start pomodoro and set loops: doro Ñ (If you type doro without specifying a number, it will perform the default number of loops that are set in the script.).

Change work time: cp work Ñ

Change break time: cp break Ñ

Keep in mind that these changes are only for the current session. If you want to make them permanent, you'll need to adjust them within the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment