ob
v0.0.4
Published
OB (The Second Terminal Printer) - A lightweight server-client tool for real-time terminal logging and progress display via Unix sockets. Ideal for CLI apps needing dynamic output management.
Maintainers
Readme
OB
.-. .-')
\ ( OO )
.-'),-----. ;-----.\
( OO' .-. '| .-. |
/ | | | || '-' /_)
\_) | |\| || .-. `.
\ | | | || | \ |
`' '-' '| '--' / 2025.07.14
`-----' `------' The Second Terminal PrinterInstallation
Server Setup
Install globally:
npm i -g obStart ob server:
obThis will display:
Cleaned up existing socket file: /tmp/log.sock
Log server listening on /tmp/log.sock
Press Ctrl+C to stop.Client Setup
In your project directory:
npm i obUsage Example
Edit process.js
import { stdout } from 'process'
import { cursorTo, clearLine } from 'readline'
import { log } from 'ob'
// Show processing progress
function showProgress(percentage, barLength = 20) {
const filled = Math.round((percentage / 100) * barLength)
const bar = '█'.repeat(filled) + '-'.repeat(barLength - filled)
// Send message to ob server
log(`Progress: [${bar}] ${percentage}%`)
// Update main window display
cursorTo(stdout, 0)
clearLine(stdout, 0)
stdout.write(`Progress: [${bar}] ${percentage}%`)
if (percentage >= 100) {
stdout.write('\n')
}
}
// Demo progress animation
let progress = 0
const interval = setInterval(() => {
showProgress(progress)
progress += 1
if (progress > 100) {
clearInterval(interval)
}
}, 16)Run the script:
node process.js