Saving more corsor positions (with tput?) in bash terminal

Posted by AndreasT on Ask Ubuntu See other posts from Ask Ubuntu or by AndreasT
Published on 2013-10-26T09:49:54Z Indexed on 2013/10/26 10:13 UTC
Read the original article Hit count: 203

Filed under:
|
|

I know that tput sc saves the current cursor position and tput rc restores it exactly where tput sc was called. The problem is that every time tput sc is called, it overwrites the previous saved position.

Is there a way to save more positions, e.g. tput sc pos1 and tput sc pos2 which can be restored with, say, tput rc pos1 and tput rc pos2 respectively? (The solution need not make use of tput, I mentioned it because it's the only command I know that handles cursor position)

If not, is there a way to at least save the cursor position locally in a function, so that if a function uses tput sc and then calls another function that runs again tput sc, then each function restores its own saved cursor position when invoking tput rc?

Thanks in advance.

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about bash