Copying terminal I/O with color

From Notes_Wiki

Home > CentOS > CentOS 6.x > Desktop tips and tricks > Copying terminal I/O with color

To copy terminal output with color various mechanisms are suggested at http://askubuntu.com/questions/394228/bash-colored-copy-paste In CentOS download ansi2html.sh from https://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh (or https://raw.githubusercontent.com/pixelb/scripts/master/scripts/ansi2html.sh ) does the trick. Use following steps to verify:

  1. Download ansi2html.sh raw from github
  2. Use "chmod +x ansi2html.sh" to make it executable
  3. Use "ls -l --color=always" to see ls output with colors on screen
  4. Now use:
    ls -l --color=always | ./ansi2html.sh > test.html
    to get the output stored in html file with colors
  5. Open file in web browser and verify
  6. To receive output on screen and send it to html simultaneously, use tee as follows:
    ls -l --color=always | tee >(./ansi2html.sh > test.html)
    Note that >( is a special operator and typing "> (" with space in between wont work


Learned the trick from http://www.linuxquestions.org/questions/linux-desktop-74/preserve-colors-when-copy-pasting-from-terminal-943213/


Home > CentOS > CentOS 6.x > Desktop tips and tricks > Copying terminal I/O with color