More on the Pomodoro Technique here: click!.

Lets just dive right in. I wanted a little command line app where I can start a timer like: timer 25 and it starts an 25minute timer. It's just so much faster, easier and more comfortable than doing this with your smartphone.

here we go:

#include <iostream>
#include <chrono>
#include <thread>
#include <zconf.h>

int main(int argc, char *argv[]) {

    if(argc < 2) {
        std::cerr << "usage: " << argv[0] << " [time]" << std::endl;
        return EXIT_FAILURE;

    char *pend;
    long mins = strtol(argv[1], &pend, 10);

    auto start = std::chrono::system_clock::now();
    auto end = start + std::chrono::seconds( 60 * mins);

    while(true) {
        std::chrono::duration diff = std::chrono::system_clock::now() - start;

        int seconds = std::chrono::duration_cast<std::chrono::seconds>(diff).count() ;
        int sec = seconds % 60;
        int min = seconds / 60;

        printf("%02i:%02i \r", min, sec);

        if(std::chrono::system_clock::now() >= end) {
            execlp("/usr/bin/say","say", "timer with:", argv[1], " minutes is done.", NULL);


    return EXIT_SUCCESS;

at the end of the timer I just call say which is a handy little program on Mac OS X. But you could any other program or just play a sound or something.

Of course I could have done a better job - but it works.

So everything I have to do now is:

timer 25 for my command line pomodoro timer. Of course you can use it for pizza etc.

nice little feature would be: timer pizza 10