When using a normal terminal application (like Konsole, for example), I regularly use
Control-L or the
clear command to clear the terminal's contents, leaving the cursor on the top. When I do this, I can still scroll up and read the output of the commands I ran previously (they are not discarded).
In Emacs shell mode (
M-x shell), I've been using
comint-clear-buffer to clear the contents of the terminal and leave the point (and prompt) on the top. The problem with this command is that it also discards the output of all the commands I have run up to that moment. Using
recenter-top-bottom doesn't help, because when I use it to position the point and prompt at the top, as soon as I input a command and hit
ENTER, the point 'jumps' back to its original position.
The question I would like to ask is: is there a command similar to
comint-clear-buffer that doesn't discard the output of previous commands?