Skip to content

Instantly share code, notes, and snippets.

@agoalofalife
Created December 25, 2025 07:16
Show Gist options
  • Select an option

  • Save agoalofalife/1d79166f206679c3cfbf993963c92efd to your computer and use it in GitHub Desktop.

Select an option

Save agoalofalife/1d79166f206679c3cfbf993963c92efd to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: ''
});
console.log("Start typing (Ctrl+C to exit):\n");
rl.on('line', (line) => {
// Move cursor up one line and clear it (removes the input echo)
process.stdout.write('\x1b[1A\x1b[2K');
// - \x1b[1A - moves cursor up one line (to where you just typed)
// - \x1b[2K - clears the entire line
// Show timestamped output
const timestamp = new Date().toLocaleTimeString();
console.log(`[${timestamp}] ${line}`);
});
rl.on('close', () => {
console.log('\nExiting...');
process.exit(0);
});
// script add record in cli and add timestamp after click the enter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment