On Saturday 03 Jun 2017 10:37:46 Toralf Förster wrote:
> On 06/03/2017 01:06 AM, Mick wrote:
> > Hi All,
> > 
> > Walter had posted a message about ANSI codes showing up in portage output.
> >  I am getting the same when I run /usr/bin/script and examine the
> > contents of the resultant file with a text editor; e.g. in Vim I get:
> > 
> > ^[[0;32m~ ^[[35m$ ^[[0mtest^H^[[K^H^[[K^H^[[K^H^[[Kecho
> > S^H^[[K|^H^[[K$term^M
> > 
> > but when I use less I can see:
> > 
> > ~ $ echo $TERM
> > 
> > Is there a way of suppressing these characters in gedit, kwrite, vim,
> > etc.?

Reading this again in the cold light of day, coffee helped too, it seems as if 
I want to strip ANSI colours in these particular applications above, but I 
don't.  I want to suppress colours in what the script command captures in a 
terminal.


> Well, one solution could be to use something like this :
> 
> # strip away escape sequences
> # hint: colorstrip() doesn't modify its argument, instead it returns the
> result
> #
> function stresc() {
>   perl -MTerm::ANSIColor=colorstrip -nle '
>     $_ = colorstrip($_);
>     s,\r,\n,g;
>     s/\x00/<0x00>/g;
>     s/\x1b\x28\x42//g;
>     s/\x1b\x5b\x4b//g;
>     print;
>   '
> }
> 
> 
> This works fine here since a while

Where do you put the above, or how to you use it?
-- 
Regards,
Mick

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to