0

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

例如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: delete from cursor until end of line with a keyboard shortcut等等,但所有答案都集中在删除当前行,而不是休息。

4

1 回答 1

1

tput cd

cd 清除到显示结束 (*)

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

于 2022-02-24T11:23:47.827 回答