Categories We Write About

Create a terminal-based Pomodoro timer

Here’s a simple terminal-based Pomodoro timer implemented in Python. It uses basic time functions and prints updates directly to the terminal.

python
import time import os def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') def countdown(minutes, label): total_seconds = minutes * 60 while total_seconds: mins, secs = divmod(total_seconds, 60) timer = f'{mins:02d}:{secs:02d}' print(f'{label} Time Remaining: {timer}', end='r') time.sleep(1) total_seconds -= 1 print() def pomodoro_timer(work_duration=25, short_break=5, long_break=15, cycles=4): for cycle in range(1, cycles + 1): clear_screen() print(f'Pomodoro Cycle {cycle} of {cycles}') countdown(work_duration, 'Work') if cycle != cycles: clear_screen() if cycle % cycles == 0: print('Time for a Long Break!') countdown(long_break, 'Long Break') else: print('Time for a Short Break!') countdown(short_break, 'Short Break') clear_screen() print('Pomodoro session complete! Great job!') if __name__ == '__main__': pomodoro_timer()

How it works:

  • Runs a work session (default 25 minutes),

  • Then short breaks (default 5 minutes),

  • After 4 cycles, a long break (default 15 minutes) happens,

  • Displays countdown timer updating every second in the terminal,

  • Clears screen between sessions for clarity.

You can customize the durations and number of cycles by changing arguments in pomodoro_timer().

Run this in your terminal:

bash
python pomodoro.py

Would you like me to add sound alerts or more features like pause/resume?

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About