feature request: command to copy entire contents of a terminal to stdout

142 views
Skip to first unread message

Timothee Cour

unread,
May 15, 2013, 4:58:07 PM5/15/13
to iterm2-...@googlegroups.com
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 ?

Aaron Meurer

unread,
May 15, 2013, 5:13:28 PM5/15/13
to iterm2-...@googlegroups.com
On Wed, May 15, 2013 at 2:58 PM, Timothee Cour <timothe...@gmail.com> wrote:
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?

Does it work to write to the tty file of the terminal you are working in (like /dev/ttys001)?

Aaron Meurer
 

* can you provide a terminal command, say retrieve_buffer_contents | grep abcd ?

--
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/groups/opt_out.
 
 

George Nachman

unread,
May 15, 2013, 8:21:15 PM5/15/13
to iterm2-...@googlegroups.com
You could do this with a coprocess, if I understand correctly what you want to do. Docs here: http://www.iterm2.com/coprocesses.html#/section/home
Reply all
Reply to author
Forward
0 new messages