我知道“清除”当前屏幕的清除命令,但它只是通过打印大量换行来做到这一点-清除的内容只是向上滚动。

是否有一种方法可以完全擦除终端之前的所有输出,以至于我即使向上滚动也无法到达它?


当前回答

手动清除终端。

⌘+K

Command+K用于较新的键盘

从shell脚本中清除终端;

/usr/bin/osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "k" using command down'

其他回答

在Mac OS X v10.10 (Yosemite)中,使用Option + Command + K清除Terminal.app中的屏幕。

手动清除终端。

⌘+K

Command+K用于较新的键盘

从shell脚本中清除终端;

/usr/bin/osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "k" using command down'

Command + K将清除之前的输出。

要清除输入的文本,首先用Command + A跳转到左边,然后用Control + K清除指针右边的文本。

可视化例子:

删除最后一个输出:

⌘ + L

清空终端:

⌘ + K

clear && printf '\e[3J'

清除所有东西,它在OS X上也能很好地工作。非常整洁。