Hacker News new | past | comments | ask | show | jobs | submit login

If you only need to clear the screen, you may want to check out clear(1).



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


My 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/Clea...


Why in the world would I do that when I can just redefine reset and have it work from every terminal?!


Hah :)

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


I'm aware, I already have

  reset() { clear && printf '\33c'; }


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: