Discussion:
[iterm2-discuss] cleaning up session log?
Lance E Sloan
2018-09-11 20:27:14 UTC
Permalink
Has anybody written a script to clean up iTerm session logs? I recently
started a session log just before executing a long and complicated set of
maintenance tasks. I thought I could clean up the log after my work was
done and turn it into documentation.

However, I see that the log faithfully recorded all of my cursor movements
(history navigation and command editing) and vi-mode command editing. I
need to clean all of that up before I can get to something readable. I
just wondered if anybody else has written a script to do that before I
start one myself.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lance E Sloan
2018-09-12 13:57:00 UTC
Permalink
I also forgot that some of the commands I'd executed started vi for me with
a file to edit. I'd like to clean up those vi sessions in the output, too.

This is turning out to be more complex than I'd expected. I wonder whether
there is some terminal-based screencasting tool I should use instead.
Ideally, it would be one that could playback a recorded session, allowing
pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I recently
started a session log just before executing a long and complicated set of
maintenance tasks. I thought I could clean up the log after my work was
done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor movements
(history navigation and command editing) and vi-mode command editing. I
need to clean all of that up before I can get to something readable. I
just wondered if anybody else has written a script to do that before I
start one myself.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-09-13 17:41:54 UTC
Permalink
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for me
with a file to edit. I'd like to clean up those vi sessions in the output,
too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I recently
started a session log just before executing a long and complicated set of
maintenance tasks. I thought I could clean up the log after my work was
done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lance E Sloan
2018-09-19 13:01:21 UTC
Permalink
Thanks, George.

That might help for logging future sessions. I don't see a way to use it
for displaying a session previously logged with iTerm2's logging features,
though.
Post by George Nachman
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for me
with a file to edit. I'd like to clean up those vi sessions in the output,
too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I recently
started a session log just before executing a long and complicated set of
maintenance tasks. I thought I could clean up the log after my work was
done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lance E Sloan
2018-09-19 13:46:19 UTC
Permalink
A workaround I've found is to take these steps:

1. Press *command-K* to clear the iTerm2 buffer.
2. Execute the command: clear; cat *name_of_iTerm2_log_file*
3. Press *command-A command-C* to select the entire iTerm2 buffer
contents and copy it to the clipboard.
4. Paste the contents of the clipboard to a document (e.g., Google Docs,
vim, word processor, etc.). It's helpful to use a monospaced font in the
document.

This works fairly well except for one thing:

When the text is copied from the iTerm2 buffer in step 3, the formatting is
not included. When the clipboard is pasted in the next step, it is always
as plain text. For example, if the iTerm2 display includes text shown in
bold or other colors, those attributes are not included when pasted into
the new document.

This feels like a bug or limitation in iTerm2's copy feature. If there's
another way to do it, I don't know of it. I've also tried the "Save
Selected Text..." feature, but that only saves plain text, too.
Post by Lance E Sloan
Thanks, George.
That might help for logging future sessions. I don't see a way to use it
for displaying a session previously logged with iTerm2's logging features,
though.
Post by George Nachman
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for me
with a file to edit. I'd like to clean up those vi sessions in the output,
too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I
recently started a session log just before executing a long and complicated
set of maintenance tasks. I thought I could clean up the log after my work
was done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-09-19 16:56:27 UTC
Permalink
Cmd-opt-c will copy preserving style
Post by Lance E Sloan
1. Press *command-K* to clear the iTerm2 buffer.
2. Execute the command: clear; cat *name_of_iTerm2_log_file*
3. Press *command-A command-C* to select the entire iTerm2 buffer
contents and copy it to the clipboard.
4. Paste the contents of the clipboard to a document (e.g., Google
Docs, vim, word processor, etc.). It's helpful to use a monospaced font in
the document.
When the text is copied from the iTerm2 buffer in step 3, the formatting
is not included. When the clipboard is pasted in the next step, it is
always as plain text. For example, if the iTerm2 display includes text
shown in bold or other colors, those attributes are not included when
pasted into the new document.
This feels like a bug or limitation in iTerm2's copy feature. If there's
another way to do it, I don't know of it. I've also tried the "Save
Selected Text..." feature, but that only saves plain text, too.
Post by Lance E Sloan
Thanks, George.
That might help for logging future sessions. I don't see a way to use it
for displaying a session previously logged with iTerm2's logging features,
though.
Post by George Nachman
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for me
with a file to edit. I'd like to clean up those vi sessions in the output,
too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I
recently started a session log just before executing a long and complicated
set of maintenance tasks. I thought I could clean up the log after my work
was done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lance E Sloan
2018-09-20 20:00:49 UTC
Permalink
That's just what I needed. I didn't see that in any of the menus. I'd
forgotten that holding down modifier keys while viewing menus sometimes
makes other choices appear.

I'd like to put my steps together in a script that will do the first three
steps, leaving the session log (with styles) in the clipboard, ready for
pasting. Are there CLI ways to do any of the following:

1. Clear the buffer (*command-K*)
2. Select the entire buffer (*command-A*)
3. Copy the selection with styles (*command-option-C*)
Post by George Nachman
Cmd-opt-c will copy preserving style
Post by Lance E Sloan
1. Press *command-K* to clear the iTerm2 buffer.
2. Execute the command: clear; cat *name_of_iTerm2_log_file*
3. Press *command-A command-C* to select the entire iTerm2 buffer
contents and copy it to the clipboard.
4. Paste the contents of the clipboard to a document (e.g., Google
Docs, vim, word processor, etc.). It's helpful to use a monospaced font in
the document.
When the text is copied from the iTerm2 buffer in step 3, the formatting
is not included. When the clipboard is pasted in the next step, it is
always as plain text. For example, if the iTerm2 display includes text
shown in bold or other colors, those attributes are not included when
pasted into the new document.
This feels like a bug or limitation in iTerm2's copy feature. If there's
another way to do it, I don't know of it. I've also tried the "Save
Selected Text..." feature, but that only saves plain text, too.
Post by Lance E Sloan
Thanks, George.
That might help for logging future sessions. I don't see a way to use
it for displaying a session previously logged with iTerm2's logging
features, though.
Post by George Nachman
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for me
with a file to edit. I'd like to clean up those vi sessions in the output,
too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I
recently started a session log just before executing a long and complicated
set of maintenance tasks. I thought I could clean up the log after my work
was done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
George Nachman
2018-09-21 16:06:12 UTC
Permalink
There are two approaches. You can use Applescript like this:
https://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript

Or you can use the still-a-work-in-progress Python API in the nightly
builds: https://iterm2.com/python-api

I'd recommend Applescript for now unless you feel adventurous.
Post by Lance E Sloan
That's just what I needed. I didn't see that in any of the menus. I'd
forgotten that holding down modifier keys while viewing menus sometimes
makes other choices appear.
I'd like to put my steps together in a script that will do the first three
steps, leaving the session log (with styles) in the clipboard, ready for
1. Clear the buffer (*command-K*)
2. Select the entire buffer (*command-A*)
3. Copy the selection with styles (*command-option-C*)
Post by George Nachman
Cmd-opt-c will copy preserving style
Post by Lance E Sloan
1. Press *command-K* to clear the iTerm2 buffer.
2. Execute the command: clear; cat *name_of_iTerm2_log_file*
3. Press *command-A command-C* to select the entire iTerm2 buffer
contents and copy it to the clipboard.
4. Paste the contents of the clipboard to a document (e.g., Google
Docs, vim, word processor, etc.). It's helpful to use a monospaced font in
the document.
When the text is copied from the iTerm2 buffer in step 3, the
formatting is not included. When the clipboard is pasted in the next step,
it is always as plain text. For example, if the iTerm2 display includes
text shown in bold or other colors, those attributes are not included when
pasted into the new document.
This feels like a bug or limitation in iTerm2's copy feature. If
there's another way to do it, I don't know of it. I've also tried the
"Save Selected Text..." feature, but that only saves plain text, too.
Post by Lance E Sloan
Thanks, George.
That might help for logging future sessions. I don't see a way to use
it for displaying a session previously logged with iTerm2's logging
features, though.
Post by George Nachman
This might help: https://asciinema.org/
Post by Lance E Sloan
I also forgot that some of the commands I'd executed started vi for
me with a file to edit. I'd like to clean up those vi sessions in the
output, too.
This is turning out to be more complex than I'd expected. I wonder
whether there is some terminal-based screencasting tool I should use
instead. Ideally, it would be one that could playback a recorded session,
allowing pause and select/copy of the text.
Post by Lance E Sloan
Has anybody written a script to clean up iTerm session logs? I
recently started a session log just before executing a long and complicated
set of maintenance tasks. I thought I could clean up the log after my work
was done and turn it into documentation.
However, I see that the log faithfully recorded all of my cursor
movements (history navigation and command editing) and vi-mode command
editing. I need to clean all of that up before I can get to something
readable. I just wondered if anybody else has written a script to do that
before I start one myself.
--
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,
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...