Shell console clearing

The

reset

command, which is part of ncurses, and is located in the ncurses-bin package on Debian, will completely clear the console. Is that what you want?

Brief summary of reset from the man page:

reset sets cooked and echo modes, turns off cbreak and raw modes, turns on new-line translation and resets any unset special characters to their default values before doing terminal initialization the same way as tset.

As discussed in https://superuser.com/questions/122911/bash-reset-and-clear-commands, and as pointed out by Erik in Shell console clearing, clear will just clear the screen, reset will (as bignose put it), "reset your terminal when it gets messed up by control sequences". Personally, I'm good at messing up my terminal, and when I clear it, I'm not looking to get anything back that was there before, so I just use reset. But ymmv.


I usually just use:

clear

From the clear man page:

clear clears your screen if this is possible.  It looks in the environ-
ment for the terminal type and then in the terminfo database to  figure
out how to clear the screen.

clear ignores any command-line parameters that may be present.

It's not an answer to your question, but you can use less, and maintain your color see: https://serverfault.com/questions/26509/colors-in-bash-after-piping-through-less

hint:

$ grep --color=always foo bar.txt | less -r

Tags:

Shell

Terminal