I had a need to capture the colored output of a long-running command line program, so I could easily share it with colleagues. Specifically, I'm running vagrant up, which generates colorful and useful output and I need to save this in a convenient format. My best solution so far uses two programs, aha and script, which are available as mainstream packages.
aha takes ANSI escape sequences and converts them to HTML markup. script fools your program into thinking it's outputting to your screen and not STDOUT, which normally disables color for many programs
I run my command in two steps:
script -q -c "vagrant up" temp.txt(-qremoves status messages and-ctells script to run the command)cat temp.txt | aha --black > output.htm(the--blackflag makes the HTML background dark)
I'm pretty happy so far, but maybe this can be combined into one line? Any thoughts? Or better commands I could use? I'm aware the python ansi2html, but this seemed easier.