Categories We Write About

Create a terminal Pomodoro app

Here’s a simple terminal-based Pomodoro app written in Python. It uses basic console output and time.sleep() for timing, and supports a standard Pomodoro cycle: 25 minutes work, 5 minutes short break, and a longer 15-minute break every 4 cycles.

python
import time import os WORK_DURATION = 25 * 60 # 25 minutes SHORT_BREAK = 5 * 60 # 5 minutes LONG_BREAK = 15 * 60 # 15 minutes CYCLES_BEFORE_LONG_BREAK = 4 def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') def countdown(seconds): while seconds: mins, secs = divmod(seconds, 60) timeformat = f'{mins:02d}:{secs:02d}' print(f'Time Remaining: {timeformat}', end='r') time.sleep(1) seconds -= 1 print() def pomodoro(): cycle = 0 try: while True: cycle += 1 clear_screen() print(f"Pomodoro Cycle {cycle}: Work for 25 minutes.") countdown(WORK_DURATION) if cycle % CYCLES_BEFORE_LONG_BREAK == 0: clear_screen() print("Time for a long break! 15 minutes.") countdown(LONG_BREAK) else: clear_screen() print("Short break: 5 minutes.") countdown(SHORT_BREAK) except KeyboardInterrupt: clear_screen() print("Pomodoro session ended. Good job!") if __name__ == '__main__': pomodoro()

How to use:

  • Run the script in a terminal.

  • It will start the Pomodoro cycles automatically.

  • Press Ctrl+C to stop anytime.

Let me know if you want me to add features like customizable timers, notifications, or sound alerts!

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