Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a Bash script that outputs results with pretty Bash colours, and I need to include the output with colors in a Word document.

I would like to avoid putting a screenshot as the ouput is lenghty. I also don't really want to go through the pain of adding colours manually in Word so I am looking for an easy way to copy the text with colours in PuTTY and paste into Word with colours.

share|improve this question

migrated from May 17 '11 at 19:06

This question came from our site for professional and enthusiast programmers.

Not really a programming question. Try Super User? – Rafe Kettler May 16 '11 at 1:21
I guess it's border line as it is more to document stuff, I'll look over there thanks. – Philippe May 16 '11 at 1:40
up vote 2 down vote accepted

You'll need to do a two-stage conversion, first to HTML then to Word. Try something like ansi2html, or Ansifilter and then copy/paste from a browser into Word. Generating a PDF from HTML should also be trivial (ask if you need information).

share|improve this answer
ansi2html is what i needed, it works as a charm, thanks – Philippe May 16 '11 at 6:41
"They do it wrong, so I'm going to do it wrong too" is rarely a valid excuse. – Ignacio Vazquez-Abrams May 17 '11 at 19:14
@Ignacio Vazquez-Abrams, "They weren't moved, so why should this one" ... is actually more the point. – Slomojo May 18 '11 at 4:47

You can also record your bash session / command output with the script command. It preserves color escape codes and can be parsed accordingly. However, it needs further processing, no direct copy/paste possible.

share|improve this answer

You must log in to answer this question.

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