0

I've tried dang near every sed command I could concoct, a bunch I found on here while searching for hints, and a few other random ideas, and I just can't figure it out.

As some background, I've been using this script for a while now to record terminal sessions on one of my workstations. It's very useful, as I tend to break things on this specific workstation and it's useful to go in and see what broke or what needs to be restored. However, the output is absolutely horrid when I open it in Sublime (I'll show an example below).

I've also tried ANSIescape/SublimeANSI to fix it, as it is supposed to help visually ameliorate such issues, but that leaves many random characters behind (I'll post a screenshot below)


Example of opening a Terminal recording in Sublime from the script above (note--I replaced the escape characters from sublime with their visual ASCII equivalent (i.e. I replaced the non-paste-able <0x1b> with the actual characters typed via keyboard)):

<0x1b>]0;me@me: /etc/xml<0x07><0x1b>[01;32mme@me<0x1b>[00m:<0x1b>[01;34m/etc/xml<0x1b>[00m$ ls -lah
total 68K
drwxr-xr-x   3 root root 4.0K May 27  2020 <0x1b>[0m<0x1b>[01;34m.<0x1b>[0m
drwxr-xr-x 197 root root  12K Feb 17 19:05 <0x1b>[01;34m..<0x1b>[0m
-rw-r--r--   1 root root 3.3K May 27  2020 catalog
-rw-r--r--   1 root root 3.2K May 27  2020 catalog.old
-rw-r--r--   1 root root  11K May 27  2020 docbook-xml.xml
-rw-r--r--   1 root root  10K May 27  2020 docbook-xml.xml.old
drwxr-xr-x   2 root root 4.0K Oct 15  2019 <0x1b>[01;34mresolver<0x1b>[0m
-rw-r--r--   1 root root 1.4K May 27  2020 sgml-data.xml
-rw-r--r--   1 root root 1.2K May 27  2020 sgml-data.xml.old
-rw-r--r--   1 root root  840 May 27  2020 xml-core.xml
-rw-r--r--   1 root root  673 May 27  2020 xml-core.xml.old
<0x1b>]0;me@me: /etc/xml<0x07><0x1b>[01;32mme@me<0x1b>[00m:<0x1b>[01;34m/etc/xml<0x1b>[00m$

Screenshot of Sublime before ANSIescape (from the link above) is applied:

[note: Screenshot is on a Mac after copying the file over--the behavior is the same on linux] enter image description here

Screenshot of Sublime before ANSIescape (from the link above) is applied:

[note: Screenshot is on a Mac after copying the file over--the behavior is the same on linux] enter image description here

As one can see, a few of the <0x1b> and <0x07> and ]0; stay in place in this method. The escapes get far worse if the file is huge.


Does anyone have any decent suggestions on either A: fixing the script I linked above such that it doesn't end up all mangled or B: making ANSIescape work for this use-case or C: stripping these characters out before I try to view the logs?

0 Answers0