Save everything from current session so far to a text file

6,443 views
Skip to first unread message

Kevin North

unread,
Jun 2, 2016, 3:57:45 PM6/2/16
to iterm2-discuss
Recently, I was working with a long-running process that outputs several hundred lines to STDOUT. After it ran, I wanted to copy its output to a text file, so I looked for a way to save my session to a text file. I couldn't find any options to do so. Neither could I scroll up through my session and copy the text I wanted - iTerm wouldn't let me scroll past a certain point, but I needed some output from earlier, too.

I know that when I started running the process, I could have redirected the output to a file or started logging my session, but neither of those options help me when I realize I want to save output to a file after I've already run a program. Being able to save everything that I've typed in or seen as output in a session to a text file would let me rescue myself in that situation. Is there a way to do so?

George Nachman

unread,
Jun 2, 2016, 7:40:19 PM6/2/16
to iterm2-...@googlegroups.com
I wanted to copy its output to a text file…

Select All and then Shell > Save Selected Text is probably your best option. If you care about colors and fonts and so on select all and then Cmd-Opt-C to "Copy With Styles", then paste it into textedit and save from there.

iTerm wouldn't let me scroll past a certain point, but I needed some output from earlier, too

The number of lines of history that get stored is configurable in Prefs > Profiles > Terminal > Scrollback Lines

Another option is to turn on Prefs > Profiles > Session > Automatically log session input to files in:. This will save the raw output with escape sequences and all, but you can always "cat" the file to replay the session.


On Thu, Jun 2, 2016 at 12:57 PM, Kevin North <kno...@huskers.unl.edu> wrote:
Recently, I was working with a long-running process that outputs several hundred lines to STDOUT. After it ran, I wanted to copy its output to a text file, so I looked for a way to save my session to a text file. I couldn't find any options to do so. Neither could I scroll up through my session and copy the text I wanted - iTerm wouldn't let me scroll past a certain point, but I needed some output from earlier, too.

I know that when I started running the process, I could have redirected the output to a file or started logging my session, but neither of those options help me when I realize I want to save output to a file after I've already run a program. Being able to save everything that I've typed in or seen as output in a session to a text file would let me rescue myself in that situation. Is there a way to do so?

--
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.
For more options, visit https://groups.google.com/d/optout.

ganskiy t.

unread,
Jan 3, 2020, 8:35:13 AM1/3/20
to iterm2-discuss
Is tmux session can't be logged? 

Feature is awesome, but I failed trying to log tmux (iterm2 integration mode) sesion and got a lot of unreadable (tmux config parameters smth like that) output from one of the sesion log files.

tmux Reported a Problem

%begin with empty command queue


I press OK, after that thousand lines of tmux config commands appears on the screen



пятница, 3 июня 2016 г., 5:40:19 UTC+6 пользователь George Nachman написал:
To unsubscribe from this group and stop receiving emails from it, send an email to iterm2-...@googlegroups.com.

George Nachman

unread,
Jan 4, 2020, 3:03:28 PM1/4/20
to iterm2-...@googlegroups.com
That is actually what was going over the wire. But I think it would make sense to omit it when you're making a plain-text log since it's essentially a control sequence. I've changed it in commit 9e2a271ca

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/3d91c8b5-e444-4dd7-a9d0-a25fdad24d35%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages