Pergunta

How do you clear the entire terminal in BASH, like the command prompt's cls command?

clear doesn't work because it doesn't actually clear anything, it just scrolls down.

Foi útil?

Solução

You're probably looking for the reset command.

However, the scroll-back buffer is not a feature of bash but of the terminal program. You didn't say what terminal program you were using.

Outras dicas

As far as I know, there isn't a way to do this any better than what clear does with bash.

I think it's a feature that could be built into the terminal you're using though. I know the Mac Terminal app has a 'Clear Scrollback' menu option (command + k) that does what you're asking for.

Why don't you try Ctrl+l (control, lowercase "L"). This works in most shells (err terminals)...

In OSX terminal -

Command ⌘+l (command, l) leads to removing last typed command from display.

Command ⌘+k (command, k) leads to removing/clearing all display buffer.

reset (type this in terminal) leads to reset of terminal in case display becomes garbled.

not sure of equivalent in other unix flavors.

xterm will allow the escape sequence ESC [3J to clear the scroll back, so you could do:

alias cls="clear; printf '\033[3J'"

Use +K. It removes the entries so I can't scroll up anymore.

So +K to clear everything including scrolling. Ctrl+L to clear terminal window but still be able to see everything when scrolling up.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top