I see a nicely colored output in my terminal.
The terminal has a "Export Text As" command but it saves a plain-text file without the colors. Same with copy&paste.
Do you know a way to save terminal output including colors?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI see a nicely colored output in my terminal.
The terminal has a "Export Text As" command but it saves a plain-text file without the colors. Same with copy&paste.
Do you know a way to save terminal output including colors?
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.
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.
⌘ + ⌥ + C
from iTerm2, open Keynote, and paste it, it will import it as table data. I haven't quite figured out how to format the data in a useful way, but there's potential there.
Sep 14, 2018 at 14:24
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.
command_which_produces_colors
produces ANSI codes, then pbcopy -Prefer rtf
just copies the text including the ANSI codes (e.g. it copies [0;34mText
for blue Text
). It seems as though converting the ANSI codes to RTF may be required as an intermediate step.
Jan 8, 2015 at 2:13
Based on @akira's answer, I came up with the following:
brew install ansifilter
)<command that produces colors> | ansifilter --rtf | pbcopy -Prefer rtf
<command that produces colors>
to force it to produce colors even though its output is piped, e.g. ls --color=always
instead of just ls
OS X has several keyboard shortcuts (hotkeys) for copying the screen. These will save your screenshots as a jpg files on the desktop. Here's a list of them:
Cmd-Shift-3 Take snapshot of the whole screen
Cmd-Shift-4 Take snapshot of the selected area
Cmd-Shift-4-Spacebar Take picture of a window
Escape Cancel
Hold Spacebar after Drawing the region Move the selected area
Hold Option Resize selected area
Hold Shift Resize selected area horizontally
or vertically
There's also a "Grab" application located in the Applications | Utilities folder that does the same job, plus has a few extra features such as delay.
Update
In Snow Leopard (10.6.8) the default screenshot format is png not jpg, although that can be changed to any one of many others -- including pdf -- using the free 3rd-party TinkerTool preference settings utility.
The way I do this is via the excellent Textmate 2 app.
I have to say it would nice if shift-cmd-c worked directly in the R console window.
In iTerm2 you can go to Edit
→ Copy with Control Sequences
to copy with the ANSI colour codes.
Then you just need something that will render ANSI colours.
Edit -> Copy Special
, where you can toggle between Plain Text and rich text options.