Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
If this is important to you, please let Apple know via apple.com/feedback/macosx.html (Applications/Utilities feedback area) or developer.apple.com/bugreporter (requires registering for a free developer account). –  Chris Page Mar 10 '12 at 21:42
add comment

3 Answers

up vote 15 down vote accepted

Amazing how posting a question boosts ones creativity.

There's a "Print" so I can also save to PDF. I can copy colored output from the PDF.

share|improve this answer
1  
This solution is perfect for maintaining colored output when creating terminal examples in a Keynote presentation. Thx! –  beausmith Sep 19 '11 at 1:25
    
@Wojtek: I think you can accept your own answer if you like it best... –  martineau Mar 4 '12 at 19:11
    
@martineau thanks (-: –  Wojtek Kruszewski Mar 6 '12 at 9:28
1  
@Wojtek: You're welcome, even though it cost me a little reputation when you unaccepted my answer... ;-) –  martineau Mar 6 '12 at 19:36
add comment

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.

share|improve this answer
    
Doesn't seme to work. First problem is that command_which_produces_colors notices it doesn't print to the console so it skips the colors. I can force some of them to print colors anyway, so following command outputs colors to the terminal: CLICOLOR=1 CLICOLOR_FORCE=1 ls -alh | tee But pbcopy copies no colors: CLICOLOR=1 CLICOLOR_FORCE=1 ls -alh | pbcopy -prefer rtf +1 for pbcopy/pbpaste commands. It's great for copying long files to clipboard: "pbcopy < longfile.txt" –  Wojtek Kruszewski Jan 13 '11 at 7:46
add comment

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.

share|improve this answer
3  
a .jpg is kind of not as nice as "pure" text. –  akira Jan 4 '11 at 18:23
2  
+1 for the lesser known shortcuts for selection area. –  Daniel Beck Jan 4 '11 at 19:05
    
@akira: The OP wants colors -- something you can't do in a plain-text format unless you count embedded ANSI escape sequences -- and those would need something to interpret them like a terminal emulator, but then you're back to the original problem. –  martineau Jan 4 '11 at 21:11
    
@martineau: depending on the capabilities of the clipboard colors are saved by markup (eg, richtext or html) when you copy from a browser or from word or from xyz. and, depending on the application that receives such marked up snippets they can show the colors AND the text quite ok. the terminal receives ascii escape sequences, correct, but just because it receives ascii escape sequences does not mean it has to a) store them (eg, think html-terminal) b) it can enhance the selected text a lot of ways (you can put different mime-types at a good clipboard at once). –  akira Jan 4 '11 at 21:48
1  
@akira A JPG is a really poor choice of image format for something like a screenshot. Large areas of single color and sharp single pixel lines etc. all over it. Fortunately, Apple are not that silly and the file it saves is a PNG. lbrandy.com/blog/2008/10/my-first-and-last-webcomic –  rjmunro Mar 1 '12 at 11:09
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.