I want to delete everything after the cursor; not just the current line, but every remaining characters after the current position.
For example of 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
This will leave the cursor at the second line, with the output of ll
remaining.
I'm looking for a way to either
delete each line using
tput el
until it reaches the saved position, so the chain of command would be:tput sc; ll; while_deleting; tput rc
. This may invoketput el
for everyline which seems like redundant but should be alright.delete everything after going back to the saved position.
I've looked into many answers such as how to delete all characters after cursor in shell, Bash: delete from cursor till end of line with a keyboard shortcut, and so on, but all the answers focus on deleting the current line, not the rest.
CodePudding user response:
tput cd
cd
Clear to end of display (*)
https://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html#SEC8