Search code examples
node.jsterminaltty

Nodejs linux watch command like functionality


What are the ways to implement linux's watch command functionality using Node.js?

When terminal stdout is replacing its content periodically? So I definitely don't need https://github.com/chjj/blessed capabilities. Just update/replace text content.

Should be a popular task, strange but couldn't google a simple solution.


Solution

  • You can use https://nodejs.org/api/readline.html#readline_readline_cursorto_stream_x_y in combination with https://nodejs.org/api/readline.html#readline_readline_clearscreendown_stream