Linux – How to reset system colors

colorslinux-mintmateterminal

I'm using Linux Mint, MATE version. I have a weird problem that occurs quite frequently when scrolling down through log files in terminal: the machine pauses for a second or two, and when it comes back my system colors have been scrambed. That is, the ANSI colours have all been mixed up – red thinks it's yellow, yellow thinks it's green etc. This affects not just terminal but several other desktop apps too: Caja (the nautilus replacement), Geany (text editor), and Gedit.

The color assignment seems random and sometimes results in unusable combinations, like white being replaced with black (not useful on a black background). I need to reboot to get the colors back.

What i assume is happening is that some strings of characters in the log file are not being escaped properly and are hitting something in the system, but i'm not technical enough to try and debug this. Is there any command i could enter which would reset all of the colors back, does anyone know?

Grateful for any advice, max

EDIT – attached screenshotenter image description here

EDIT – I'm using MATE Terminal 1.2.1

Best Answer

Issuing binary characters to the terminal screen is risky, as some control sequences are interpreted as commands that change the terminal mode, and not only for colors. This is because the Linux terminal emulates the antique VT100 console (with additions). See this post for a good explanation of the problem.

To sanitize your tty use one or several of the following commands :

  • reset
  • stty sane
  • tput init
  • tput reset

A surer way might be to use the stty command to save and reset all your setting at once:

  1. Use stty -g to print the current settings in stty-readable format
  2. Copy the resulting string
  3. Add to your shell init file (.bashrc or whatever) the alias (s for sane) as :
    alias s='stty <output string from step 2>'
  4. Now when confusion occurs, just type : s Enter
Related Question