我有以下 BASH 函数,它接受参数并将它们显示在终端底部的新行中,该行被排除在滚动区域之外:
bottomLine() {
clear
# Get all arguments and assign them to a var
CONTENT=$@
# Save cursor position
tput sc
# Add a new line
tput il 1
# Change scroll region to exclude the last lines
tput csr 0 $(($(tput lines) - 3))
# Move cursor to bottom line
tput cup $(tput lines) 0
# Clear to the end of the line
tput el
# Echo the content on that row
echo -ne "${CONTENT}"
# Restore cursor position
tput rc
}
它相当简单并且有效。事情是,在一些命令之后(有时只是几个,有时在工作 15 分钟之后),即使它应该被排除在滚动区域之外,它也会向上滚动。
这在蒂尔达和终结者中都发生在我身上。
任何帮助将不胜感激,干杯。
编辑:重现此问题的最佳方法是,如果您执行几次“ls -a,ls -a,ls -a,ls -a”直到到达页面底部,然后使用 Vi 打开一个随机文件,然后执行另一个“ls -a”。当你这样做时,不可滚动的底行会在上面,即使它不应该。