reset
has its place, but clears your screen. If you are running xterm
or anything compatible, the shortest, least intrusive thing to use would be
printf '\033[?9l'
That is not explicitly stated in the Mouse Tracking section of XTerm Control Sequences, but xterm
allows you to reset (disable) mouse mode by turning off any of the possible modes that might be turned on. Those are documented as named constants:
#define SET_X10_MOUSE 9
#define SET_VT200_MOUSE 1000
#define SET_VT200_HIGHLIGHT_MOUSE 1001
#define SET_BTN_EVENT_MOUSE 1002
#define SET_ANY_EVENT_MOUSE 1003
and 9
is the shortest.
Mouse-mode is turned on by many applications. If one exits without turning it off, that produces the odd characters which you saw. ncurses applications turn mouse-mode off in endwin
, which all well-behaved curses application call. Other applications may not use (n)curses, or may forget to call endwin
.
ncurses applications check if xterm-mouse mode is available by testing for the kmous
capability (which is part of the screen
terminal description). That has been the standard way to test for the feature since 1999, so it is unlikely that an application turned mouse mode on accidentally. Rather, it indicates an application that forgot to do its job.
There is, by the way, no screen.xterm
entry in Debian's ncurses-term
package (keeping it is more helpful than removing it). Here is a list of all of the screen-related entries in that package. Most are used for fixing discrepancies in screen
behavior for various terminals:
/usr/share/terminfo/s/screen.konsole
/usr/share/terminfo/s/screen-16color-bce
/usr/share/terminfo/s/screen-16color
/usr/share/terminfo/s/screen3
/usr/share/terminfo/s/screen.mrxvt
/usr/share/terminfo/s/screen-bce.Eterm
/usr/share/terminfo/s/screen-bce.gnome
/usr/share/terminfo/s/screen.xterm-xfree86
/usr/share/terminfo/s/screen-bce.konsole
/usr/share/terminfo/s/screen-bce.mlterm
/usr/share/terminfo/s/screen-256color-s
/usr/share/terminfo/s/screen-bce.mrxvt
/usr/share/terminfo/s/screen-bce.rxvt
/usr/share/terminfo/s/screen.linux
/usr/share/terminfo/s/screen.vte
/usr/share/terminfo/s/screen-bce.xterm-new
/usr/share/terminfo/s/screen.teraterm
/usr/share/terminfo/s/screen-16color-bce-s
/usr/share/terminfo/s/screen.xterm-r6
/usr/share/terminfo/s/screen+fkeys
/usr/share/terminfo/s/screen-256color-bce-s
/usr/share/terminfo/s/screen.mlterm
/usr/share/terminfo/s/screen-16color-s
/usr/share/terminfo/s/screen-bce.linux
/usr/share/terminfo/s/screen.gnome
/usr/share/terminfo/s/screen.rxvt
/usr/share/terminfo/s/screen2
/usr/share/terminfo/s/screen.Eterm
/usr/share/terminfo/s/screen.xterm-new
tmux
from time to time too. At some point the terminal multiplexers seem to go banana and decode the inputs incorrectly (xterm
might also have something to say here).reset
usually fixes this for me.reset
works in screen too! Thanks for the fix, however, I'd love some insight as to why...