1 |
On 06/03/2017 01:06 AM, Mick 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 |
Well, one solution could be to use something like this : |
17 |
|
18 |
# strip away escape sequences |
19 |
# hint: colorstrip() doesn't modify its argument, instead it returns the |
20 |
result |
21 |
# |
22 |
function stresc() { |
23 |
perl -MTerm::ANSIColor=colorstrip -nle ' |
24 |
$_ = colorstrip($_); |
25 |
s,\r,\n,g; |
26 |
s/\x00/<0x00>/g; |
27 |
s/\x1b\x28\x42//g; |
28 |
s/\x1b\x5b\x4b//g; |
29 |
print; |
30 |
' |
31 |
} |
32 |
|
33 |
|
34 |
This works fine here since a while |
35 |
|
36 |
-- |
37 |
|
38 |
Toralf |
39 |
PGP 23217DA7 9B888F45 |