You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal: provide an action to clear the terminal #6603
Similar to the output panel would be nice to have an action top right to clear the terminal contents.
Reacted by Ignat Ignatov, Nripendra Nath Newa, Mohsen Azimi, Shane Parsons, Rohan Gulati, Tai, tachuris, Siddhartha Gandhi, dan, Abhinav Gauniyal and 7 more
That's what esc[2J does. esc[H additionally positions the caret in the top left corner. The problem remains that we don't know in what context we clear the terminal and therefore don't know how to properly prompt for input or if we even should clear the terminal in the first place.
Exposing this in upstream would make things a lot more convenient for consumers, all they will need to do it xterm.clear() then. It should also be much safer since eraseInDisplay should really not be exposed, also sending key codes will fail if the terminal is currently executing a process.
Activity
Tyriar commentedon Jun 30, 2016
This will probably involve sending a particular key sequence to the xterm object.
chrmarti commentedon Jul 11, 2016
The following clears the terminal with two (related) issues:
There will be no prompt after clearing (like: bash-3.2$ )
Clearing while running something like vim or top will leave the terminal unusable.
const esc = String.fromCharCode(27);
this.xterm.write(
${esc}[H${esc}[2J);I'd suggest to not implement this and rely on the shell's built-in clearing (like
clearin bash).Tyriar commentedon Jul 11, 2016
How about calling into
eraseInDisplaywith Erase All arguments?chrmarti commentedon Jul 11, 2016
That's what
esc[2Jdoes.esc[Hadditionally positions the caret in the top left corner. The problem remains that we don't know in what context we clear the terminal and therefore don't know how to properly prompt for input or if we even should clear the terminal in the first place.Tyriar commentedon Jul 11, 2016
You're right, I still think this should be done but it will need to be done upstream xtermjs/xterm.js#173
chrmarti commentedon Jul 11, 2016
There is a CSI code to lookup the current cursor position. That and a few others could potentially be used to delete all lines except the current one.
Tyriar commentedon Jul 11, 2016
Exposing this in upstream would make things a lot more convenient for consumers, all they will need to do it
xterm.clear()then. It should also be much safer sinceeraseInDisplayshould really not be exposed, also sending key codes will fail if the terminal is currently executing a process.Implement clear terminal command
Tyriar commentedon Sep 17, 2016
Added the API in upstream and implemented the command. The ⌘K keybinding on mac is still blocked by #12187
Tyriar commentedon Sep 25, 2016
Moved the keybinding to #12585 as it's not going to land for Sept.