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:
- Running the Terminal for the whole session with the terminal width that I want to appear in the printed output, and
- 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.)
Best Answer
Before starting your session, run the command
bash | tee stdout.rtf
. This starts a new bash session, recording the output in a filestdout.rtf
. Now, simply editstdout.rtf
and print.