9

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

3
  • have you tried command reset in the terminal?
    – mnmnc
    Jan 7, 2013 at 10:58
  • Does the problem persist if you open a new terminal?
    – terdon
    Jan 8, 2013 at 18:22
  • @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. Jan 21, 2013 at 17:03

2 Answers 2

12
+25

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
8
  • Thanks, i'll try this next time it happens and comment to let you know. Jan 7, 2013 at 13:30
  • Ok, it's just happened! I tried all the commands in your list and also the longer 4-step process you describe. No luck. Jan 21, 2013 at 17:06
  • BTW, i am using MATE Terminal 1.2.1 Jan 21, 2013 at 17:09
  • I have no experience with MATE Terminal, sorry.
    – harrymc
    Jan 21, 2013 at 17:26
  • I should try a different terminal i think... Jan 23, 2013 at 14:13
2

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

tput sgr0

From documentation:

tput sgr0 – Turn off all attributes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .