4 ms·
> reset should be a last resort. If you need to use it then something else has gone wrong and thats what needs to be fixed. Er, my comment was exaggerative? (e
by dataflow 3y ago
> reset should be a last resort. If you need to use it then something else has gone wrong and thats what needs to be fixed.
Er, my comment was exaggerative? (edit: fixed typo)
I use reset all the time, it's not "last resort" by any means. It... clears the screen and scrollback buffer. If you're the kind of person who keeps 150 tabs open then I guess I can see why you wouldn't see the value in cleaning the screen up frequently, but clearing the terminal is a pretty frequent and useful operation for other folks.
- sidneythekidney 3y agoIf you only need to clear the screen, you may want to check out clear(1).
- dataflow 3y agoI literally edited my comment just before you said this because I suddenly realized someone was going to say this. No, the point is never just the "screen". The point is the whole buffer including the screen. Clearing just the screen is pretty useless to me, I might as well just scroll down or hold Enter for 3 seconds.
- sidneythekidney 3y agoHah :) You could try echo -ne '\ec' or echo -ne '\033c'. Or this from bash/readline: clear-display (M-C-l) Clear the screen and, if possible, the terminal's scrollback buffer, then redraw the current line, leaving the current line at the top of the screen. But yea, this might depend on terminal as well
- dataflow 3y agoI'm aware, I already have reset() { clear && printf '\33c'; }
- Ennea 3y agoMy terminal emulator of choice, WezTerm, has this feature built in [1], so there's no need for using `reset`. Perhaps your terminal emulator has something like it, too? [1] https://wezfurlong.org/wezterm/config/lua/keyassignment/ClearScrollback.html https://wezfurlong.org/wezterm/config/lua/keyassignment/Clea...
- dataflow 3y agoWhy in the world would I do that when I can just redefine reset and have it work from every terminal?!
- extraduder_ire 3y ago> Clearing just the screen is pretty useless to me, I might as well just scroll down or hold Enter for 3 seconds. I actually do that a lot, when I'm done with a terminal window for now but want the scrollback to stay there. ctrl-L to send a pagebreak is what I usually do, or typing something aliased to `clear`.
- rezonant 3y agoFwiw parent comment currently says exaggerative, not aggressive. Why wouldn't you use "clear" for that, or Ctrl+L? "reset" does a lot more, you use it when you've accidentally written a binary to your terminal and triggered a bunch of terminal modes. I guess clear wouldn't clear the scroll buffer, is that the main reason?
- dataflow 3y ago> I guess clear wouldn't clear the scroll buffer, is that the main reason? Yes. See sibling replies.
- Propelloni 3y agoI think that's a libvte pecularity (used among others by the Gnome and XFCE terminal emulators), which upon entering <clear> (or pressing CTRL+L) just scrolls up until the screen seems to be empty. Make sure you set terminfo correctly, ie. E3=ED3, so that it clears the text and scroll buffer. On any non-libvte using terminal emulator, eg. xterm, you can use CTRL+L to clear the text area and ALT+CTRL+L to clear the text area and the scroll buffer.
- krab 3y agoMy Gnome terminal only scrolls on CTRL+L or CTRL+ALT+L but it actually clears the buffer after the clear command.
- Propelloni 3y agoYay, another irregular behaviour! If you are interested in a history of weird behaviours, take a look at https://invisible-island.net/xterm/xterm.faq.html#bug_gnometerm https://invisible-island.net/xterm/xterm.faq.html#bug_gnomet... ;)
- deleted 3y ago[deleted]
- hnlmorg 3y ago> Er, my comment was aggressive? No it wasn’t. But I also said exaggerative not aggressive. > I use reset all the time, it's not "last resort" by any means. It clears the screen. That’s what ‘clear’ is for. Reset is intended to do more than just clear the screen. It’s intended to reset, as the name suggests, the entire terminal. The idea being it’s got itself into some kind of unknown state. There are hot keys to clear your screen too, such as ctrl+L (works in most shells) plus your terminal emulator will likely have its own hot keys too. So fewer button presses and even quicker for you.
- dataflow 3y agoClearing 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
- oefrha 3y agoIf you need reset(1) to clear the screen and scrollback buffer all the time (it shouldn’t clear the buffer btw, don’t know why you think it does if you really do it all the time), consider using your terminal emulator’s native keyboard shortcut, it’s faster to type, faster to run, you can do it at any time without the shell yielding control back to you, and it doesn’t pollute the shell history. If your terminal emulator doesn’t even have that, I suggest switching to a better one. I hope you realize you’re doing something really suboptimal here. Edit: Saw your other comment and apparently you don’t even use reset(1), just your own function (which is still suboptimal like I said). WTF is with all the arguing then.