Copy colored output from Mac OS X terminal

Amazing how posting a question boosts ones creativity.

I can open "Print" dialog and save to PDF and then copy colored output from the PDF.

Also iTerm2 terminal app has a shortcut CMDOPTC that copies with formatting.


It appears that if you select text in the Terminal, then copy it, then paste it into an application that supports rich text (e.g. Mail, TextEdit, Word), then the text color will be preserved.

It appears that in Mail and TextEdit, the background color of the terminal is also pasted; in Word, it is not. I'm not sure how to explain this discrepancy.


you can try to paste the colored output to the clipboard like this:

% command_which_produces_colors | pbcopy -prefer rtf

which puts some rtf (possibly colored and formated) stuff into the pasteboard of macos. you can then use any other that understands richtext to access the clipboard.

this is obviously not the same as "select it with the mouse" but maybe worth a shot.