Pomodoro timer in the shell

13 March 2021

A pomodoro timer for the shell below—works in bash and zsh; drop this into your .bashrc or .zshrc and pomodoro whenever you need help with motivation.

For those of you who are not sure what the pomodoro technique is, the below is from wikipedia:

The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. The technique uses a timer to break down work into intervals, traditionally 25 minutes in length, separated by short breaks. Each interval is known as a pomodoro, from the Italian word for ‘tomato’, after the tomato-shaped kitchen timer that Cirillo used as a university student.

Also from wikipedia, this is how it might work in practice:

  1. Decide on the task to be done.
  2. Set the pomodoro timer (traditionally to 25 minutes).
  3. Work on the task.
  4. End work when the timer rings and put a checkmark on a piece of paper.
  5. If you have fewer than four checkmarks, take a short break (3–5 minutes) and then return to step 2; otherwise continue to step 6.
  6. After four pomodoros, take a longer break (15–30 minutes), reset your checkmark count to zero, then go to step 1.

function pomodoro {
    VOLSTR="[[volm 0.5]]"

    # See if timezone already set and set if not
    if [[ -z "${TZ}" ]]; then
        # You should change below to your timezone
        # ls /usr/share/zoneinfo
        # for options
        export TZ="Europe/London"

        # Check timezone is valid
        export TZ_FILE="/usr/share/zoneinfo/$TZ"
        if [ ! -f "$TZ_FILE" ]; then
            echo "$TZ_FILE does not exist."

        # See https://unix.stackexchange.com/a/48104 for explainer on colon
        if [[ $TZ != ":"* ]]; then

        echo "Using timezone $TZ"

    let c=1

    # Start pomodoro sessions from 1 if not set
    if [ "$pomodoro_count" -eq 0 ]; then
        let pomodoro_count=1

    echo "Pomodoro session $pomodoro_count"

    echo "Starting timer"
    if [ $(uname) = "Darwin" ]; then
        say "$VOLSTR Starting timer"

    echo -n "Timing from "
    echo "$(date +%H:%M:%S)"

    while true; do
        sleep 60
        echo -n " $c "
        echo -ne "$(date +%H:%M:%S)"
        echo ""
        let c=c+1
        if [ "$c" -gt "30" ]; then
            echo "Pomodoro"
            if [ $(uname) = "Darwin" ]; then
                say "$VOLSTR Pomodoro"

    let pomodoro_count+=1