6 ms·
Maybe someone here can help. I have a major usability problem with this. It actually seems to be a regression from cmd.exe. I often like to run `cls; build -
by recursive 7y ago
Maybe someone here can help. I have a major usability problem with this. It actually seems to be a regression from cmd.exe.
I often like to run `cls; build -with -long -output;`. And then I scroll to the top to see the first build error. With this, when you issue a clear, it only blanks the visible viewport, and you can still scroll back through all the old stuff.
https://github.com/microsoft/terminal/issues/1305 https://github.com/microsoft/terminal/issues/1305
There's a lot of information here that's over my head about how this actually isn't a bug, and different pieces of trivia and history. But I still can't use it for my use case, which is a thing I do often.
- zenexer 7y agoIf you're using PowerShell Core, add the following to Documents\PowerShell\Profile.ps1. If you're using legacy PowerShell, add it to Documents\PowerShell\Microsoft.PowerShell_profile.ps1 instead. Remove-Alias cls function cls { echo "$([char]27)c" } A similar solution was provided in the GitHub issue that works on older versions of Windows Terminal.
- recursive 7y agoI don't know if I'm using "Legacy" Powershell. `(Get-Host).Version` reports 5.1.18362.145. I added your workaround to both .ps1 files. It doesn't change any behavior in any obvious way. Even if it did, it's still a work-around at best. If this actually worked, I can't imagine a reason this shouldn't be built in to the product. But I really don't think it works. Regardless of whether any of these profile scripts are taking effect, invoking `echo "$([char]27)c"` directly also doesn't clear the scroll history, so I doubt it would even work even if I could figure out how create a profile script. I did notice that there were a number of other proposed work-arounds in the github thread. Each one of them seems to have some feedback saying that it doesn't work. In my opinion, this is shortcoming of this product.
- zenexer 7y agoIt looks like others have already given you long explanations of why PowerShell works this way. Nevertheless, the behavior you're describing can still be desirable at times. In the future, the following will probably work: echo "$([char]27)[3J$([char]27)[H$([char]27)[2J" This matches the output from `tput clear` in WSL. However, as of writing, it's a bit quirky when combined with other PowerShell commands; for example, the following behaves oddly: ls; echo "$([char]27)[3J$([char]27)[H$([char]27)[2J"; ls Unfortunately, I don't have a good solution at the moment.
- recursive 7y agoTo be honest, it's pretty much all over my head. I'm just a simple man, trying to clear my console. The only way to do it seems to be completely restart it, which I guess is ok, but certainly inconvenient. I'll probably check back in on Microsoft Terminal in a few months and see if any of the terminal wizards have discovered a way to clear the console.
- JdeBP 7y agoUsing the RIS control sequence is a bad idea. Its long-standing functionality has included completely resetting the serial communications at the terminal end. ED (Erase Display) is the control sequence to use for clearing the screen in systems with a terminal I/O paradigm. Emit it twice, as ED 2 to clear the whole main screen and as ED 3 to separately clear the scrollback buffer. * http://jdebp.uk./FGA/clearing-the-tui-screen.html http://jdebp.uk./FGA/clearing-the-tui-screen.html
- zenexer 7y agoNormally it's not what I'd use, but Windows Terminal still has some quirks. It was the only thing that seemed to work reliably. However, now that I've done additional testing, even that doesn't seem to work reliably. Keep in mind that the context here is finding a workaround for a specific terminal emulator. Very cool link and bit of history, though!
- JdeBP 7y agoThe workaround, which isn't really a workaround at all because it's the standard way of doing this (plus a fairly modest common extension that we terminal emulator authors have mostly agreed upon), has already been found. The Microsoft people in the GitHub issue said to use ED 2 and ED 3, as well. I merely additionally explained why your doing something that they did not suggest is wrong, not only for the reasons that the Microsoft people already said, but for the additional reasons that it has a standard function that is not what is desired here.
- zenexer 7y agoIt doesn't work, though, as I've already explained elsewhere in the comment tree. It works in naive examples, but fails to clear at the correct time in more complex situations.
- jiggawatts 7y agoYeah, this is the canary in the coal mine for me. The Windows behaviour is correct, the Linux behaviour is inconsistent and was kept for historical reasons only. Microsoft has been overrun with developers who think that whenever there's a conflict between the Windows and Linux ways of doing things, then automatically the Linux way is correct, because of a 60-year old UNIX legacy that must be preserved forever and ever. Even on different operating systems. Even in green-fields codebases being developed in 2020. Even if it makes no sense at all. Even if it's a regression compared to what Windows does now. This is not the only example. Mark my words, it's just a matter of time until junior Microsoft devs reintroduce all of the stupidities from Linux that have no place in any sane operating system: * Button action occurs on mouse-down instead of mouse-up, making misclicks uncancellable. * No delete key support to match Linux backspace-only behaviour: https://unix.stackexchange.com/questions/66434/delete-key-doesnt-work-on-command-line https://unix.stackexchange.com/questions/66434/delete-key-do... * Cursor key support is removed in favour of vim-style hjkl movement keys that make sense only on ADM-3A terminals from the 70s: https://superuser.com/a/599152 https://superuser.com/a/599152 * Selection copies instantly, wiping out your clipboard whether you like it or not. * All output becomes text, because strong typing is for soft people that haven't mastered sed/awk. * PowerShell is replaced by bash, because why would anyone need consistent naming, readable scripts, and pervasive tab-complete? We want to save precious bytes on our 300 baud SSH connections! * SSH for Windows instead of WinRM, which has been included for a decade.
- rswail 7y agoI doubt "junior Microsoft devs" reintroduce what you think is somehow related to Linux. And a "sane" operating system is independent of shells (whether *sh or PowerShell or cmd) and is also independent of the GUI running on it. Button action is related to the GUI you're running, not Linux. Delete key actions are related to termcap which indeed is historical. However, any sane GUI terminal handles that. How many people actually operate a windows machine via a serial port? Cursor key support: I used terminals in the 70s and 80s. Many of them had arrow keys that were supported. See termcap above that was specifically to handle these sorts of issues. Multiple clipboards, again, are dependent on your GUI, it has nothing to do with the terminal or the PTTY underneath it in Linux/Unix. All output becomes text, is actually a misnomer. It is that all output (by default) comes out of stdout and is an octet stream. SSH didn't exist when there were 300 (or 110) baud connections. TTYs did and devices like the VT-52 that supported certain escape sequences to do things that were relevant to a screen as opposed to a printer with keyboard attached. SSH vs WinRM. Neither were around when the Unix TTY/PTTY/line drivers etc were established. In fact, telnet and rlogin weren't around either. They're not even comparable. SSH establishes an encrypted tunnel between processes, WinRM is a SOAP API client/server protocol for performing remote admin. But hey, tell us what you think about systemd.
- JdeBP 7y agoPart of your problem is self-inflicted. The deficiencies of the CLS command have been known for about a quarter of a century, long before Windows Terminal was even an idea. It's why 4NT, later to become TCC, added a /C option to its CLS command, making it clear the entire screen buffer instead of just the window rectangle. * https://jpsoft.com/help/cls.htm https://jpsoft.com/help/cls.htm * http://jdebp.uk./FGA/clearing-the-tui-screen.html http://jdebp.uk./FGA/clearing-the-tui-screen.html
- recursive 7y agoI have never heard of 4NT or TCC. By the way, the problem also affects the `Clear-Host` powershell command. `cls` seems to work exactly how I want outside this new Terminal program, so it's hard to understand how it could have been so well known.
- jdance 7y agoI feel your pain, and I have a hard time processing the other comments here, I just really want to empty my terminal buffer, its really useful. In the game I’m building I have a quake style ”dropdown” console and clear() was very easy to implement :)