views:

1176

answers:

1

I see in the AppleScript dictionary that the current screen's worth of text and the history buffer are available as properties.

How would I AppleScript that to copy the contents of the currently selected Terminal.app tab to the paste buffer?

Could I do it on the command line?

What about the whole history log?

+1  A: 

To copy the contents of the currently selected Terminal.app from the command-line:

osascript <<END
  tell application "Terminal"
    tell front window
      set the clipboard to contents of selected tab as text
    end
  end
END

For the history:

osascript <<END
  tell application "Terminal"
    tell front window
      set the clipboard to history of selected tab as text
    end
  end
END
albertb