Created
December 25, 2025 07:16
-
-
Save agoalofalife/1d79166f206679c3cfbf993963c92efd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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