I've just run some commands and have several pages of output in iTerm2. Now I'd like to save it somewhere. (I could have piped it to a file, but I didn't think of that.)

Is there an easier way to copy it all to the clipboard that by scrolling back and highlighting for pages?

3 Answers 3


Oh, right, duh. + A to select it all, then + C.

  • 2
    There is a setting in iTerm 2 that automatically copies anything selected to the clipboard, making the Command-C unnecessary.
    – Ɱark Ƭ
    Commented Jul 17, 2014 at 17:34
  • 1
    I did this, but saving a 100M scrollback log through clipboard took iTerm2 about 5 min, and a bit less - to paste it into a text editor. I wish Cmd-S saved the buffer directly. Commented Jan 5, 2017 at 0:55
  • 8
    pbpaste > ~/Desktop/buffer.log took milliseconds for 17meg file
    – Drew
    Commented Mar 7, 2017 at 14:04

To capture your history of commands (but not their output):

history > ~/Desktop/history.txt

If you want output as well, the shell command script works as well to capture while you type (but it captures key presses too, so watch out) or iTerm will have some option to save a session, like the stock Terminal's + S.

  • 7
    this will only save your commands, and not their output Commented Jul 1, 2019 at 17:18

Click Shell -> Export text as...

Or press ⌘ + S.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .