3

This is probably a long shot but it would be really handy if there is a solution. I am logged in on a work computer I currently cannot access. I know the output of a long running job I previously started is on an iTerm2 window.

I have SSH access to the machine and I would like to read the contents of that window. Is there, e.g., a file where iTerm2 backs up session output? Or any other way to read the content of an open window? Obviously it's too late to select any specific session logging options. Usually after a forced restart, the iTerm2 window will restore the previous output so I presume it is saved somewhere.

  • Use tmux or screen to save the history of terminal sessions. It is usually not possible with generic terminal emulators. – Jakuje Jul 4 '17 at 18:11
  • @jakuje Thanks, but it's an existing session I want, not a future one. – jarmond Jul 4 '17 at 18:29
  • I would also add I have tried grabbing a remote screenshot with screencapture utility and by Applescript to no avail. – jarmond Jul 4 '17 at 18:31
1

This was discussed some time ago on Unix.SE and the bottom line is that there is no general way of doing that, unless you

  • want to search for that data in the memory of the terminal process
  • you want a terminal that support querying for the buffers (some says xterm knows that)
  • You have your commands running in screen/tmux

I would not like to discourage you nor any other possible answerers. Maybe there is some Apple-specific way I don't know about.

0

You can now do automated session logging in iTerm. The docs on this aren't super clear but the feature does exist.

  • To enable session logging for a single session: Session > Log > Start
  • To disable it Session > Log > Stop

To automate this for all sessions of a given profile e.g., Default:

  • Preferences > Profiles > Default > Session > Automatically log session input to files in

A logfile can be read back easily with cat, e.g., cat foo.log. If you enable auto logging everywhere, then I recommend stopping it for the current session before you cat back a previous log to avoid confusing output.

You can customize the template string for the session log filenames in Preferences > Advanced > Format for automatic session log filenames.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .