Comment 3 for bug 1876768

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

The same applies not just for the mouse mode, but a whole lot of other terminal modes (e.g. keypad modes, alternate charset, alternate scroll mode, bracketed paste mode, colors, attributes and many many more...).

The problem cannot be fixed in the terminal: The terminal, by design, only sees a single continuous stream of instructions to execute. It has no idea where they come from, e.g. remote or local, ssh or not. It cannot figure out when is the time to override those instructions.

A reasonable place to fix this would be the shell prompt (or a hardwired behavior of the shell, to reset these modes whenever it prints the prompt). You can customize your PS1 to include the escape sequence that switches off mouse mode, and whatever else you wish. (Don't forget to wrap these in \[ \] as per the PROMPTING section in bash's manual.)

I agree that either upstream bash, or downstream distributions by configuring PS1 accordingly, should do their best to minimalize the risk of such situations, i.e. reset as many of the terminal modes as reasonable. I myself used to do it in my personal PS1 until I got bored of maintaining it and stopped caring, the problems are so rare that I just execute "reset" or close the terminal and open a new one :)