Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active May 27, 2022
Embed
What would you like to do?
A Pomodoro timer for the macOS terminal

Blog 2020/6/23

<- previous | index | next ->

A Pomodoro timer for the macOS terminal

Here is a simple Pomodoro timer for the Mac command line.

When time is up, your Mac speaks the phrase "Hey Pomodoro, time's up!".

pomo.sh:

#!/bin/bash

# A Pomodoro timer for the macOS terminal.

set -e

if test -z "$1"
then
    echo "Usage: $( basename $0 ) <duration in minutes>" >&2
    exit 1
fi

minutes=$1

echo "Starting a Pomodoro timer of $minutes minutes."

i=0
while test $i -lt $minutes
do
    sleep 60
    i=$(( $i + 1))
    echo $i minutes elapsed
done

echo "Hey Pomodoro, time's up!"
say "hey pomodoro, times up"

Console output:

$ pomo.sh 45
Starting a Pomodoro timer of 45 minutes.
1 minutes elapsed
2 minutes elapsed
3 minutes elapsed
...
43 minutes elapsed
44 minutes elapsed
45 minutes elapsed
Hey Pomodoro, time's up!
@CHAIYOMIN
Copy link

CHAIYOMIN commented May 27, 2022

thanks! love your way to use say in terminal

@cellularmitosis
Copy link
Author

cellularmitosis commented May 27, 2022

@CHAIYOMIN 👍

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