How to reset system colors

9

2

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

Max Williams

Posted 2012-12-21T11:07:44.053

Reputation: 2 237

have you tried command reset in the terminal? – mnmnc – 2013-01-07T10:58:22.917

Does the problem persist if you open a new terminal? – terdon – 2013-01-08T18:22:06.303

@mnmnc - yep, no effect. terdon - yes it persists if i open a new terminal. It's just done it again for the first time in ages. – Max Williams – 2013-01-21T17:03:29.747

Answers

12

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

harrymc

Posted 2012-12-21T11:07:44.053

Reputation: 306 093

Thanks, i'll try this next time it happens and comment to let you know. – Max Williams – 2013-01-07T13:30:54.230

Ok, it's just happened! I tried all the commands in your list and also the longer 4-step process you describe. No luck. – Max Williams – 2013-01-21T17:06:47.150

BTW, i am using MATE Terminal 1.2.1 – Max Williams – 2013-01-21T17:09:09.237

I have no experience with MATE Terminal, sorry. – harrymc – 2013-01-21T17:26:50.347

I should try a different terminal i think... – Max Williams – 2013-01-23T14:13:56.017

Probably so ... – harrymc – 2013-01-23T15:48:20.770

I've been using gnome-terminal instead and just had the same problem for the first time. So i don't think it's the termninal's fault. – Max Williams – 2013-02-06T09:57:25.717

You will always have this problem with printing binary files to any tty-emulation console. The problem is unavoidable, but there are solutions, as detailed above, which work for most terminals. – harrymc – 2013-02-06T10:45:31.677

2

Correct answer is (at least it worked in my case):

tput sgr0

From documentation:

tput sgr0 – Turn off all attributes

Ľuboš Katrinec

Posted 2012-12-21T11:07:44.053

Reputation: 21