真正清除终端屏幕
在终端上使用 clear
命令只会让用户误以为屏幕已被清除……当您使用鼠标滚动时,您仍然可以看到先前命令的输出.当你淹没在文本海啸中时,这会让你的生活变得困难.
Using the clear
command on the terminal only fools the user into thinking the screen has been cleared...you can still see output from the previous commands when you scroll using the mouse. This makes life difficult when you are drowning in a tsunami of text.
可以在 Internet 上找到的各种解决方案(转义码等)只是 clear 命令已经执行的功能的变体.
Various solutions (escape code etc.) which can be found on the Internet are only variations of what the clear command already does.
那么如何在 Linux 中真正清除终端的内容?
So how do you clear the contents of a terminal in Linux for real?
使用下面的命令来清屏而不是仅仅添加新行...
Use the following command to do a clear screen instead of merely adding new lines ...
printf " 33c"
是的,这是 bash 提示符下的printf".
yes that's a 'printf' on the bash prompt.
你可能想定义一个别名...
You will probably want to define an alias though...
alias cls='printf " 33c"'
说明