4 ms·
Clearing just the screen without the scrollback history is pretty damn useless and in fact outright frustrating. It boggles my mind people read "clear the scree
by dataflow 3y ago
Clearing just the screen without the scrollback history is pretty damn useless and in fact outright frustrating. It boggles my mind people read "clear the screen" and think "oh, surely he doesn't want to clear the scrollback buffer". You have to realize, a command for that is so close to useless it doesn't even exist as a separate operation on Windows. Over there, cls ("CLear Screen") does both and is incredibly handy. And on the incredibly rare occasions when I actively want to keep the scrollback buffer (read: like once every 2 months, tops?), I can already do that much more intuitively by scrolling down or holding Enter for 3 seconds. I don't need a separate command for it any more than I need a separate command to scroll down.
- hnlmorg 3y ago`reset` doesn't even clear the scrollback buffer on all terminal emulators. In fact there's no formal specification for how scrollback buffers should behave because they're a modern incantation. Take iTerm2, this is what happens when I run `reset` and then scroll up: lmorg ~ % reset lmorg ~ % reset lmorg ~ % which reset /usr/bin/reset lmorg ~ % You might find the ANSI escape code for reset, {ESC}c, does what you need: function reset { printf '\033c' } The above code should work on sh, Bash, Zsh, Oil and Murex.
- dataflow 3y ago> You might find the ANSI escape code for reset, {ESC}c, does what you need: See https://news.ycombinator.com/item?id=39638794 https://news.ycombinator.com/item?id=39638794
- hnlmorg 3y agoIf you've already got a working solution then I don't see why this is problem. The way you've conversed in this thread sounds like it's a daily annoyance for you.
- dataflow 3y agoIt was one for several years, until I solved it like this. It was such an unnecessary waste of my time. And it would not have taken nearly that long if everyone's response to "how to clear the terminal on Linux" on Google wasn't "clear" or "Ctrl+L".
- hnlmorg 3y agoGoogles response is correct though. The scroll back is a “new” concept introduced by terminal emulators. It’s not something that ever existed in hardware terminals or even early pseudo-terminals (like the default console Linux drops you into if you don’t have a GUI installed). It’s just something that desktop software added. Because of this, there isn’t really any standardisation for how scrollback should work. Every terminal could implement it differently (albeit in practice there isn’t a whole lot of variation one can do to such a simple concept). So support for how you clear your scrollback is going to vary from one terminal emulator to another. As I demonstrated in an earlier comment with ‘reset’ not clearing the scrollback on one terminal in macOS. Really there should be a dedicated ANSI escape code for doing this. There’s a few different codes for clearing the terminal already, one extra wouldn’t do any harm there. Plus xterm has already introduced the concept of bespoke codes for application terms like window title (something other terms have expanded on with codes to move the terminal window). In fact, I’m going to create a code for just this and implement it in my own terminal emulator and others are welcome to adopt this as a new de facto standard if they wish. Anyway, that’s the history of why you had such a hard time. None of this is intended to justify the status quo, and I do accept that this is all a bit frustrating to newcomers. But as I said before, I don’t agree the solution is to change the purpose of ‘reset’. Instead terminal emulators should be supporting new functionality to manage something that they added to the paradigm — and to be fair, most terminal emulators already do.
- seba_dos1 3y ago> It’s not something that ever existed in hardware terminals or even early pseudo-terminals (like the default console Linux drops you into if you don’t have a GUI installed). FWIW, the default Linux console had scrollback until a few years ago when it was removed in Linux 5.9. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=50145474f6ef4a9c19205b173da6264a644c7489 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...