Skip to content

Instantly share code, notes, and snippets.

@joparara
Created August 25, 2025 09:48
Show Gist options
  • Save joparara/fa89be4274345efd8dd7353f0daf759c to your computer and use it in GitHub Desktop.
Save joparara/fa89be4274345efd8dd7353f0daf759c to your computer and use it in GitHub Desktop.
pomodoro-js
// Note: Idea from https://www.reddit.com/r/commandline/comments/nqf8an/probably_the_simplest_pomodoro_timer_cli_for_linux/
const fs = require('fs');
const path = require('path');
function pomo() {
// Process command-line arguments
const args = process.argv.slice(2);
const durationMinutes = parseInt(args[0], 10);
const taskMessage = args.slice(1).join(' ');
// Validate arguments
if (isNaN(durationMinutes) || !taskMessage) {
console.error('Usage: node pomo.js <duration_in_minutes> <task_message>');
process.exit(1);
}
const durationMilliseconds = durationMinutes * 60 * 1000;
const logFile = path.join(process.env.HOME, '.pomo_log.txt');
const startTime = new Date().toISOString();
console.log(`Starting Pomodoro session: ${taskMessage} for ${durationMinutes} minutes.`);
// Log the start of the session
const startLogEntry = `START: ${startTime} | DURATION: ${durationMinutes} min | TASK: ${taskMessage}\n`;
fs.appendFileSync(logFile, startLogEntry);
// Set the timer
setTimeout(() => {
// Log the end of the session
const endTime = new Date().toISOString();
const endLogEntry = `END: ${endTime} | TASK: ${taskMessage}\n`;
fs.appendFileSync(logFile, endLogEntry);
// Echo the completion message
console.log("DONE POMODORO!!");
}, durationMilliseconds);
}
pomo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment