2

I was wondering about the functionality of the clear (https://invisible-island.net/ncurses/man/clear.1.html) command, that I can evoke with CtrlL in my Terminal.app on macOS.

When executed, it should move my cursor to the top of the screen - what it does. That's great. But it has a side effect as well: It creates a whole lot of white space (depending on the screen size) on top of the command. For example look at this command line history:

➜  ~ some command
command
output
➜  ~ clear

➜ ~ # the input line is now on top; but there is a lot of whitespace in the history as well

This is kind of bloating my command line history, when I scroll back. So I'm wondering, why is this white-space on top created?

tbrodbeck
  • 185
  • 6
    What terminal emulator are you using? This has nothing to do with the command history, it is just the terminal's buffer fro scrollback, but I can't reproduce it. What terminal are you using that lets you scroll back past the clear command? Or are you using something like screen or tmux? – terdon Sep 26 '20 at 09:39
  • Presumably running the clear command doesn't have this side-effect – Chris Davies Sep 26 '20 at 09:44
  • What's Terminal.app? There's no such application in Linux. Is it MacOS X? – Artem S. Tashkinov Sep 26 '20 at 09:48
  • On my Mac, it looks like it scrolls the current visible area out into the scrollback, so that it's not lost when the screen is cleared. You'll see that if you fill the screen with anything before running clear, you only get one empty line then. Of course it could detect that part of the screen was already empty and not store that, but that's more work. Not an answer since I don't know if this is the actual why. – ilkkachu Sep 26 '20 at 11:36
  • @annahri yes, when you use CTRL+L. I was testing with the actual clear command. – terdon Sep 26 '20 at 11:40
  • I see. I thought that they do the same thing, at least practically. – annahri Sep 26 '20 at 11:47
  • 3
    Ah look! It is https://unix.stackexchange.com/q/375743/5132 again, except with Terminal.app instead of GNOME Terminal. – JdeBP Sep 26 '20 at 12:41
  • @ArtemS.Tashkinov @terdon I am using the macOS default Terminal. I just created a tmux shell in it and the issue did not appear anymore. Thanks for clarifying, then it seems to be a issue of the Terminal.app – tbrodbeck Sep 27 '20 at 09:24

0 Answers0