Just press Ctrl-L on the keyboard.
CtrlL to scroll the current line to the top. The scrollback is not erased.
clear -xto erase the all the lines that are not in the scrollback.
clearto erase all the lines, including the scrollback.
CtrlL is a binding of GNU readline library, which,
as Bash manual page says, is what handles reading input when using an
Clear the screen leaving the current line at the top of the screen.
The CtrlL binding can be reassigned in
clear, on the other hand, is an external command.
$ type clear clear is /usr/bin/clear
From its manual page,
clearclears your screen if this is possible, including its scrollback buffer
(if the extended “E3” capability is defined).
-xdo not attempt to clear the terminal’s scrollback buffer using the
extended “E3” capability.
clear command does not clear scrollback for me. so
clear or ^L works.
In newer versions of clear, it seems that the default behaviour has been changed.
To clear the screen and keep scrollback use the option
To have the previous behaviour create an alias such as:
If you pipe the output to
less, then not only will it clear the screen and show your output at the top, but it will switch back to the previous screen contents when you exit.