Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't clear the terminal programmatically #950

Closed
fabiospampinato opened this issue Sep 6, 2017 · 4 comments
Closed

Can't clear the terminal programmatically #950

fabiospampinato opened this issue Sep 6, 2017 · 4 comments
Labels
type/question A question on how to use the library

Comments

@fabiospampinato
Copy link

Running node -e "process.stdout.write ( '\u001Bc' );" should clear the terminal, but this is what I get if I run it in xterm:

screen shot 2017-09-06 at 23 16 44

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?

@Tyriar
Copy link
Member

Tyriar commented Sep 6, 2017

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).

@Tyriar Tyriar closed this as completed Sep 6, 2017
@Tyriar Tyriar added the type/question A question on how to use the library label Sep 6, 2017
@fabiospampinato
Copy link
Author

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 added a commit to fabiospampinato/cliflix that referenced this issue Sep 6, 2017
@Tyriar
Copy link
Member

Tyriar commented Sep 6, 2017

@fabiospampinato it looks like clear command on Linux sends '\x1b[H\x1b[2J'

That translates into:

  • Move cursor to (1,1) (CUP)
  • Erase all in display (ED)

See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html for more info

@fabiospampinato
Copy link
Author

That works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question A question on how to use the library
Projects
None yet
Development

No branches or pull requests

2 participants