I have installed the new iTerm 2. It asked me in a yellow bar at the top if I\'d like to enable a mouse feature. Unfortunately I don\'t remember the exact sentence anymore.
The behavior you're seeing is the expected (and correct) behavior when in the alternate screen. The only problem you have is that you dropped into bash, or whatever, on the alternate screen, possibly while losing a connection or from a killed vim or less. EG you were in less +F /var/log/something
and got disconnected.
You see someone has already written that the tput rmcup
command will exit to the main screen.
I also went ahead and looked up some terminal control characters. It can be any of: ESC [ ? 1 0 4 9 l
or ESC [ ? 1 0 4 7 l
or ESC [ ? 47 l
(gnu.org/software/screen/manual/html_node/Control-Sequences.html) with a preference to the first.
I'm generally successful in iTerm2 with echo -e '\e[?1049l'
I actually don't find rmcup
any easier to remember, restore memory of console up?.