A very similar question has already been asked on SuperUser but none of the answers works satisfactorily for me.

I can actually get almost what I want by simply:

  1. Running the Terminal for the whole session with the terminal width that I want to appear in the printed output, and
  2. Using Command-P (⌘-P) to print the terminal scrollback history (including colors!) to PDFwriter.

However, I can't then edit the terminal scrollback history before printing.

If I save the Terminal Saved Output with ⌘-S, I can edit the text, but it is plaintext only—no colors.

I want to use this printing capability to create correctly colorized example output PDFs demonstrating the correct use of command line tools, so it is important that I be able to edit the scrollback history for clarity. For instance, if I make a typo halfway through a long demonstration, I don't want the mistake to appear in the PDF to confuse students/readers, but I also don't want to restart the demonstration.

Really I would like to be able to add page breaks at specific points, and have page numbering. But at the very least I must be able to edit the text before it is turned into a PDF.

How can I do this on Mac OS X?

(I'm running Lion, 10.7.4.)

1 Answer 1


Before starting your session, run the command bash | tee stdout.rtf. This starts a new bash session, recording the output in a file stdout.rtf. Now, simply edit stdout.rtf and print.

  • This doesn't work. (a) The command output isn't displayed to my terminal, only the prompts are displayed; (b) The commands I type aren't entered into the file; (c) The command output is not in color.
    – Wildcard
    Commented Mar 18, 2016 at 5:49
  • I fixed it, it should work now! Commented Mar 18, 2016 at 6:04
  • Better, but still no colors. You can't do it just with redirection.
    – Wildcard
    Commented Mar 18, 2016 at 6:18
  • try copying (m4-a m4-c) your terminal and paste it into a text editor that supports color. mod4 is normally the apple key. Commented Mar 18, 2016 at 15:20

You must log in to answer this question.

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