Running node -e "process.stdout.write ( '\u001Bc' );"
should clear the terminal, but this is what I get if I run it in xterm:
If I try to clear it with a node -e "process.stdout.write ( '\033[2J\033[0f' );"
the whole thing becomes black.
Is there a way it can be cleared properly?
Using node -e "process.stdout.write ( '\u001Bc' );"
or echo -e '\x1bc'
tell bash to clear, and bash gives back a response to xterm.js. I believe this is why you're seeing the prompt again. You can call term.write('\x1bc')
to clear only the front end (xterm.js).
What if I don't have access to the xterm instance?
I basically want to clear the terminal when my CLI app starts, how am I supposed to do that if it gets launched from xterm?
@fabiospampinato it looks like clear
command on Linux sends '\x1b[H\x1b[2J'
That translates into:
CUP
)ED
)See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html for more info
That works, thank you!