weird characters in log session

616 views
Skip to first unread message

Ioannis Tsitsiklis

unread,
Aug 23, 2021, 2:32:34 AM8/23/21
to iterm2-discuss
Hello everyone,

I use iTerm quite sometime now, but only recently I needed to enable the log session.
when not in plain text I get a lot of weird characters.
I believe that is because I use fish as a shell, but would love to keep it and have the logs as expected if possible. I seen similar behavior when on zsh but seems to work fine with bash
Any ideas?
Thanks

Last login: Mon Aug 23 09:27:59 on ttys001
Welcome to fish, the friendly interactive shell
Type [32mhelp (B [m for instructions on how to use fish
[?2004h ]0;fish /Users/user [30m (B [m
[92muser (B [m@ (B [mgrathdt27170 (B [m [32m~ (B [m (B [m> [K
[24Chost www.google.com
[43C [19D [38;2;0;95;215mhost [30m (B [m [38;2;0;175;255mwww.google.com
[43C [30m (B [m
[30m (B [m [?2004l ]0;host www.google.com /Users/user [30m (B [m
www.google.com has address 142.250.186.36
www.google.com has IPv6 address 2a00:1450:4017:806::2004
[2m⏎ (B [m
[K [?2004h ]0;fish /Users/user [30m (B [m
[92muser (B [m@ (B [mgrathdt27170 (B [m [32m~ (B [m (B [m> [K
[24C ]0;fish /Users/user [30m (B [m

[92muser (B [m@ (B [mgrathdt27170 (B [m [32m~ (B [m (B [m> [J
[24C ]0;fish /Users/user [30m (B [m

[92muser (B [m@ (B [mgrathdt27170 (B [m [32m~ (B [m (B [m> [J
[24C

Richard Mitchell

unread,
Aug 23, 2021, 6:05:10 AM8/23/21
to iterm2-discuss

Those look like normal ascii escape codes to enable colors, etc.  I'm guessing both your fish and zsh setup colorizes output and  bash does not?

Ioannis Tsitsiklis

unread,
Aug 23, 2021, 1:14:05 PM8/23/21
to iterm2-discuss
yes indeed they are, but I am not sure if I can have the fish/zsh colorization and the log session.

plain text works as fine, in log session btw

Richard Mitchell

unread,
Aug 23, 2021, 1:26:01 PM8/23/21
to iterm2-discuss
Your options, as I see it, are:
1: disable fancy colorizations for purpose of saving a log session
2: post filter the log session to remove escape codes
3: wait for George to add another option.

for number 1,  I assume you're only saving selective sessions, not everything.

for number 2, lolcat has a routine to filter out escape codes (otherwise it would fail in exciting ways),
I suspect there are other more direct tools for doing the same.

Ioannis Tsitsiklis

unread,
Aug 24, 2021, 9:27:44 AM8/24/21
to iterm2-discuss

1. well plain text works for now without weird characters so this is what I am using, or just go with bash
2. did not know this was doable , I will have a look

thanks for your response !!

George Nachman

unread,
Aug 24, 2021, 6:04:39 PM8/24/21
to iterm2-...@googlegroups.com
I think what you’re asking for is to log to a format like RTF so that you can see colors without control sequences?

--
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iterm2-discuss/1c3ca60a-f860-47e0-95fd-abd196b5db0cn%40googlegroups.com.

Adrian Bool

unread,
Aug 26, 2021, 4:51:38 PM8/26/21
to iterm2-...@googlegroups.com
Hi Ioannis,

On 24 Aug 2021, at 14:27, Ioannis Tsitsiklis <i.tsit...@gmail.com> wrote:
1. well plain text works for now without weird characters so this is what I am using, or just go with bash
2. did not know this was doable , I will have a look

One easy thing you could try, is using,

less -R <filename>

I think you you find that shows the content of the file with the colour intact — not showing the control chars themselves.  Perhaps this is even better than filtering that data out at source?

Cheers,

aid


Ioannis Tsitsiklis

unread,
Aug 27, 2021, 4:29:06 AM8/27/21
to iterm2-discuss

That would be great if possible

Ioannis Tsitsiklis

unread,
Aug 27, 2021, 4:37:35 AM8/27/21
to iterm2-discuss
I am not sure it works as expected. I get the random characters but with colour 
or I am not using the command properly

I attached a sample if that helps

logtest.log

Adrian Bool

unread,
Aug 27, 2021, 12:31:14 PM8/27/21
to iterm2-...@googlegroups.com
Hi Ioannis

On my (Catlina) system, viewing your provided file using less with no additional parameters gives me:


Using less -R gives me:


And then "less -r" (i.e. lower case) gives me the slightly better:



Further down the file I can still see the ^H (backspace) chars:


Using "less -rU <filename>" tidies these up:



Good to check "echo $LESS" to see if you have any settings within an environment variable.  Personally, I do set this environment variable in my ~/.profile with:

export LESS=-Xr


Do get the same?

(All screenshots taken from within iTerm, of course! ;-) )

Cheers,

aid


-- 
You received this message because you are subscribed to the Google Groups "iterm2-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-discus...@googlegroups.com.

Richard Mitchell

unread,
Aug 27, 2021, 1:19:31 PM8/27/21
to iterm2-discuss
great analysis!

I was going to post a screenshot (png) of just the first 20 lines or so, but kept getting an "error" (with no indication from google the actual error), so I gave up.  Yours was a much better response.

George Nachman

unread,
Aug 27, 2021, 1:29:55 PM8/27/21
to iterm2-...@googlegroups.com
RTF is a bad choice because it doesn’t seem you can append to it, and I don’t want to keep the whole thing in memory as one giant string.

The next most obvious choice is HTML. It’ll be wordy and barely valid, though. Something like:

<span style=“background-color: #000; color: #fff”>hello <b>world</b></span>

If anyone’s got a better idea I’m all ears :)

George Nachman

unread,
Aug 28, 2021, 2:05:26 PM8/28/21
to iterm2-...@googlegroups.com
Commit afffabf8c396e5f753943493497629187b17bda3 adds support for logging as HTML. It’ll be in the next nightly build, due out in 14 hours.

Ioannis Tsitsiklis

unread,
Aug 30, 2021, 3:05:46 PM8/30/21
to iterm2-discuss
Thank you all for the interest so far.

I tested the nightly build a bit.
The HTML type seems to be working fine, although I have not done any extensive test, but so far all good.


I would appreciate if you could let me know off the following as well, because I think I broke something in my item installation.
I have not noticed that before since I never used the logging option prior to my post.
In both the nightly and stable build, either on fish shell or bash, I get in the log every keypress, such as up arrow, or left arrow to fill a command etc.
I am attaching also examples .
In the fish shell I get the whole "command", you can see a lot of repeated "dig www.google.com" for example. These are up-arrows
In  bash you can see the characters "[K" or [C"

Maybe it is normal but just wanted to know if it is normal.


Again thank you very much for the help
fish_html.html
fish_plaintext.log
bash_raw.log

George Nachman

unread,
Sep 14, 2021, 1:58:19 PM9/14/21
to iterm2-...@googlegroups.com
Yes, this is normal. The raw data log includes everything sent by the shell. Different shells will redraw in their own ways.

Ioannis Tsitsiklis

unread,
Sep 19, 2021, 8:57:12 AM9/19/21
to iterm2-discuss
Thanks for replying George.
I just discovered that this happens on all 3 different Linux machines I use as well, so I guess it is a Nix thing.
Really appreciate the help

HTML format for logs is working quite well for me ;)

Reply all
Reply to author
Forward
0 new messages