要在运行PuTTY时清除控制台屏幕和回滚缓冲区,这对我有用:
echo -en "\ec\e[3J"
实际上,这是2个独立起作用的“ Esc”序列...可以按以下顺序使用它们:
# clears the console screen, but not the scrollback buffer
# this is actually the escape code to "reset" the terminal
echo -en "\ec"
# clears the scrollback buffer, but not the console screen
# screen content remains, and cursor position remains at its last position
echo -en "\e[3J"
使用echo -en "\ec"
哪个复位终端可以更改其他一些终端设置。代替“重置”,您可以这样做:
# position the cursor to "Home" (Top Row, First Column)
echo -en "\e[H"
# Erase down: clear the screen from the cursor down to the bottom of the screen.
echo -en "\e[J"
# Note: this is supposed to clear the screen and position the cursor to home,
# but it didn't work like that for me. It cleared the entire screen (above and
# below the cursor), but left the cursor at its last position.
echo -en "\e[2J"
# putting everything together
echo -en "\e[H\e[J\e[3J"
您可以将其放在shell脚本中,并且效果很好。
如果存在一些系统依赖性:
我正在将PuTTY连接管理器(版本0.7.1 BETA(内部版本136))与PuTTY(版本0.60)一起使用。
输入:
echo \"$TERM\"; /bin/sh --version
报告:
"xterm"
GNU bash, version 4.1.2(1)-release-(x86_64-redhat-linux-gnu) ...