I'd like to get entire contents of a terminal window to stdout to make it easy to write tools that, say, grep for a string inside it.
* iterm allows to do (on osx ) command A+ command C to copy entire contents to clipboard, which can then be fed to pbpaste to have it in stdout
but that is an ugly hack and affects the clibboard.
* i tried an applescript but it's also ugly / buggy
tell application "iTerm"
set output to contents of last session of current terminal
do shell script "echo " & quoted form of output & "some_file.txt"
end tell
* can the apple script above be modified to at least return to stdout without requiring a file?
* can you provide a terminal command, say retrieve_buffer_contents | grep abcd ?