I am running a java script, which has some text output. I'd like to copy/paste that output. If I do ⌘-A, it copies everything that's been typed that session, even if I typed clear beforehand. How can I copy only what is currently displayed?

  • Use your mouse to select the text you want to copy and hit ⌘-C or Right-click then copy. – romainl Jun 16 '14 at 20:01
  • It's a lot of text. This would take forever – Adam_G Jun 16 '14 at 20:26
  • 3
    "only what is currently displayed?" is almost certainly less than 80 lines. It would take what? Half a second? A full second? – romainl Jun 16 '14 at 20:34
  • How would you possibly know what my java program outputs? It's about 10,000 lines – Adam_G Jun 16 '14 at 21:19
  • 3
    I have no idea what your program outputs but you asked "How can I copy only what is currently displayed?" So… do you want to copy the whole output (use pbcopy) or "what's currently displayed" (select then Cmd+C)? – romainl Jun 16 '14 at 21:54

echo 'sup3ru53r' | pbcopy

  • Select the text and copy (⌘ cmd+C)
  • What do I put in place of sup3ru53r? – Adam_G Jun 16 '14 at 20:27
  • The thing you want to copy. I'm not familiar with java but you need to type the command to run the script instead of the echo sup3ru53r – ᔕᖺᘎᕊ Jun 16 '14 at 20:34

Without modifying your code, you can...:

  • Set the number of buffered lines equal to your screen size, in Terminal Preferences. It can be found under the Settings tab, and then the Windows button.
  • Clear the scrollback buffer with cmd-K immediately before running your script, then use cmd-A C as normal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.