Whilst I know that tput rmcup
returns from the "alternate screen" (referred to as "cup mode" in man 5 terminfo
) and restores the saved screen, it does have the side-effect of repositioning the cursor.
So if tput smcup
was called, tput rmcup
restores the screen and repositions the cursor, but if you then type a few more commands or press enter a few times and then use tput rmcup
again, the cursor returns to the original saved position.
One use case is in a bash
script that replays a terminal recording [using scriptreplay
]: if the script ends prematurely without [the equivalent of] calling tput rmcup
then I'd like to be able to detect that in my bash
script and call tput rmcup
automatically.
So in short, I'd like to be able to determine what the current screen state is; i.e., is it the "alternate screen" or is it the "normal screen"?