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:
- Download ansi2html.sh raw from github
- Use "chmod +x ansi2html.sh" to make it executable
- Use "ls -l --color=always" to see ls output with colors on screen
- Now use:
- ls -l --color=always | ./ansi2html.sh > test.html
- to get the output stored in html file with colors
- Open file in web browser and verify
- 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