I use the screen
command for command-line multitasking in Linux and I set my scrollback buffer length to a very large value. Is there a key combination to clear the buffer for a certain tab when I don't want it sitting there anymore?

- 2,336
- 5
- 31
- 40
-
See http://stackoverflow.com/questions/10932487/gnu-screen-how-to-clear-scrollback-and-screen-at-once for how to clear the screen at the same time. – Alastair Irvine Mar 02 '17 at 02:01
7 Answers
This thread has the following suggestion:
In the window whose scrollback you want to delete, set the scrollback to zero, then return it to its normal value (in your case, 15000).
If you want, you can bind this to a key:
bind / eval "scrollback 0" "scrollback 15000"
You can issue the scrollback 0
command from the session as well, after typing C-a :
.
HTH.

- 4,635
- 8
- 34
- 38

- 50,406
- 14
- 85
- 110
-
-
12Google aside, the purpose of Stack Overflow is to be the place for canonical answers, so I for one am fine with things being duplicated in a place where I know they can be found. – Drew Stephens May 17 '09 at 16:55
-
That's why I had wuoted the solution as well. And we could argue about google but with those simple keywords it was the very first hit for me. And actually I had read that message on the mailing list when it was posted, that's why I had remembered. – Zsolt Botykai May 17 '09 at 20:09
-
A dumber but easier to remember / type alternative `yes | head -100000`, or just `yes | cat -n`, or `seq 1 999999` and Ctrl-C when you see a number higher than your scrollback length. Only on a local terminal though, might be too slow on a remote connection. Assuming you want to purge sensitive info. from the scroll back - if you just want an empty scroll back, the answer's the way to go. – Terry Brown Oct 27 '18 at 14:56
C-a C
will clear the screen, including the promptclear
(command, not key combination) will clear the screen, leaving a prompt
ETA: misread the original question; these will just clear the visible text, but will not clear the buffer!

- 3,130
- 1
- 19
- 17
-
None of those clear the scrollback buffer though; and the second one creates a new screen window, leaving the previous one still there (press `C-a a` to get back to it). – Greg Hewgill Sep 22 '08 at 06:27
-
I misread the original question, and made a mistake with the second -- thought I could clear that out before spreading the misinformation, but I underestimated how fast people are here :-) (FTR, my original comment had `C-a c` as another solution) – Athena Sep 22 '08 at 06:36
-
3I noticed there's a difference between `C-a c` (Ctrl-C + lowercase c) and `C-a C` (Ctrl-C + uppercase C). The lowercase one creates a new screen window and a new shell, and the second one actually clears the current window. – elifiner Feb 09 '15 at 13:19
I added the command "clear" as well to clean the current screen. N.B. You have to press enter to regain you prompt.
bind '/' eval "clear" "scrollback 0" "scrollback 15000"
Also add it to you ".screenrc" to make it permanent.
N.B. I added single quotes around the slash to be sure it didn't interfere in my ".screenrc". May not be necessary.

- 51,025
- 31
- 133
- 161

- 111
- 1
- 3
-
That's not what the OP asked for. This is not an answer - the bit that is duplicates the other answers. – itsbruce Oct 31 '12 at 15:11
Command-K seems to be best solution for Mac. For more details and explanations, please refer to this page.

- 1
- 1

- 125
- 1
- 5
-
2This refers to a command in the MacOS X "Terminal" program and has nothing to do with GNU screen. – Alastair Irvine Mar 02 '17 at 01:59
From the man page:
C-a C (clear) Clear the screen.
-
1simple enough misunderstanding, but do read the questions for details – Fire Crow Nov 27 '09 at 18:24