I was curious if there is a way to clear the terminal buffer/output through some keyboard shortcut. I am using Ubuntu. I am aware that

ctrl+L

clears the terminal, but you can still scroll back to see the old text. I am looking for something similar to what

reset 

command does. On Mac

apple + k 

seems to do the trick.

link|improve this question
feedback

migrated from stackoverflow.com Jun 21 '11 at 2:17

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 3 down vote accepted

In gnome terminal, you can edit the keyboard shortcuts with Edit -> Reset Shortcuts... You can then map the command "Reset and Clear", which seems to do what you're looking for.

Alternatively, you can limit the scrollback history to a small number (say 0) and Ctrl+L will be closer to what you are looking for.

link|improve this answer
Thanks, the shortcut thing works! – Naveen Jun 21 '11 at 1:21
feedback

Ctrl+L redraws the terminal; it doesn't clear it. If you're in a full-screen app like less or vim, the Ctrl-L command is what you use to redraw a corrupted screen. In vim with color syntax highlighting, for example, you can use ctrl_l to update the colors if you scroll a long distance and vim gets confused by matching quotes or brackets or similar.

Just for reference if someone searches and finds this... If you need to clear the scroll-back buffer, either set your buffer to 0 lines or close the window and reopen it. Or "while true; do print; done" and then interrupt with ctrl+c when you've output enough lines to blow the buffer. The scroll buffer is application dependent, so while the given solution works for Gnome terminal, it won't work for really any other terminal device.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown