如何删除光标后的所有内容



我想删除光标后的所有内容;不仅是当前行,而且是当前位置之后的每一个剩余字符。

例如tput sc; ll; tput rc:

root@test:~# tput sc; ll; tput rc
root@test:~# {CURRENT_CURSOR_POSITION}
drwx------  5 root root  4096 Feb 23 16:34 ./
drwxr-xr-x 25 root root  4096 Jul  1  2021 ../
-rw-------  1 root root    59 Feb 23 16:34 .bash_history
-rw-r--r--  1 root root  3106 Dec  5  2019 .bashrc
drwxr-xr-x  3 root root  4096 Feb  8 17:07 .local/
-rw-r--r--  1 root root   161 Dec  5  2019 .profile
drwxr-xr-x  3 root root  4096 Jun 21  2021 snap/
drwx------  2 root root  4096 Feb 22 11:56 .ssh/
-rw-------  1 root root 12976 Feb  8 17:07 .viminfo

这将使光标停留在第二行,同时保留ll的输出。

我正在寻找一种方法

  1. 使用tput el删除每一行,直到它到达保存的位置,因此命令链将为:tput sc; ll; while_deleting; tput rc。这可能会为每一行调用tput el,这看起来是多余的,但应该是可以的。

  2. 在返回保存位置后删除所有

我已经研究了很多答案,比如如何删除shell中光标后面的所有字符,Bash:用键盘快捷键从光标删除到行尾,等等,但所有的答案都集中在删除当前行,而不是其他行。

tput cd

cd清除至显示结束(*(

https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html#SEC8

最新更新