Read iTerm2 last session output history
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.