Gentoo Archives: gentoo-user

From: R0b0t1 <r030t1@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How do I turn off ansi (colour) codes in ... script output
Date: Sat, 03 Jun 2017 00:12:14
Message-Id: CAAD4mYjdavzUAFxXxZfdxPXRz729jXXnkYfPH-wd--9o4hvUyw@mail.gmail.com
In Reply to: [gentoo-user] How do I turn off ansi (colour) codes in ... script output by Mick
1 On Fri, Jun 2, 2017 at 6:06 PM, Mick <michaelkintzios@×××××.com> wrote:
2 > Hi All,
3 >
4 > Walter had posted a message about ANSI codes showing up in portage output. I
5 > am getting the same when I run /usr/bin/script and examine the contents of the
6 > resultant file with a text editor; e.g. in Vim I get:
7 >
8 > ^[[0;32m~ ^[[35m$ ^[[0mtest^H^[[K^H^[[K^H^[[K^H^[[Kecho S^H^[[K|^H^[[K$term^M
9 >
10 > but when I use less I can see:
11 >
12 > ~ $ echo $TERM
13 >
14 > Is there a way of suppressing these characters in gedit, kwrite, vim, etc.?
15 > --
16 > Regards,
17 > Mick
18
19 The proper way to approach this is to disable coloring in the program
20 generating your output. If there is no flag for it, you can try
21 setting your terminal capabilities such that color is not supported
22 (e.g. TERM=xterm-old, possibly unsupported on BSDs). However for some
23 poorly written programs that may not work. Lastly, you can strip the
24 escape sequences from the output.
25
26 See http://www.andre-simon.de/doku/ansifilter/en/ansifilter.php if you
27 are interested in the latter option. This seems the easiest to do if
28 you don't mind the extra step.

Replies