When I want to provide a visual break after a long list of output lines from a command I normally run clear
so that the terminal will clear the screen, put my prompt back at 0,0 while also keeping the history (vs reset
).
The problem is that when I scroll up, the terminal is now back to the long lines of output, without any kind of break in history.
I had the idea of "echo'ing a screen's worth of empty lines" by doing yes '' | head -n $(tput lines)
, but then my cursor is at the bottom of the screen. So I try to run clear
but it seems to remove the empty lines. I also tried tput cup 0 0
but that also removes the empty lines (I guess by "reverting" my screen's worth of empty lines).
I can force the empty lines by printing any character with yes
instead of the empty string, or I can print some character/message at the end of the empty lines. But now I'm adding garbage.
The only thing I've been able to get to work is:
yes '' | head -n $(($(tput lines) * 2))
tput cup 0 0
Is there another way or is this my only option?