How to send colored terminal text to the printer - linux

Is there a way to convert colored text in the terminal to something printable?
I have an output from icdiff (https://github.com/jeffkaufman/icdiff) that present a colored diff side-by-side in my linux terminal (xterm on debian 9.3). As far as I understand the output is colored using ANSI escape codes. I would like to see the same text with the same colors in a printable document, e.g. pdf. Is that possible? Google gives no usable results.

Related

How to make the input and output color different in Terminal?

In Pycharm-run, the input text color is always green and Italic while the output is always in plain text in white, which really helps me to distinguish the input from the output. How do I do that in Linux terminal or in VSCode?
I use Linux mint and i can easily change the color of font , color of palette, output color, size and all by opening the terminal -> Edit -> Preferences. It has all the options .I hope this helps.
open the bash terminal
go to .bashrc using vi or nano
at the end of the file add the PS1
PS1="\e[1;31m\u#\h \W$ \e[0;0m"
This code at the end of the rc file will make your prompt red and bold
There are many ways you can change by manipulating the characters in it.
Here is an useful link: https://phoenixnap.com/kb/change-bash-prompt-linux

Which ANSI code should I use to make text muted (dark gray)?

When I use code 1;30m it produces different results:
Xshell 5: gray and bold
PhpStorm terminal: only bold
Windows console: only gray
The goal is to make a part of text to be slightly muted, but if it possible, it should display similarly in most terminal clients.
Anyway I don't understand how "bold" flag can change the foreground color. What am I doing wrong?
ANSI didn't specify that. ANSI listed black, red, etc., and also mentions bold. How a particular terminal displays bold+black is implementation-defined (no standard applies).
"ANSI" refers to x3.64, withdrawn many years ago, replaced by ECMA-48 (aka ISO 6429).
For your amusement:
ECMA-48:
Control Functions for Coded Character Sets
Aren't bright colors the same as bold? (xterm FAQ)
How do I get color with VT100? (ncurses FAQ)
Confirmed, on xterm that displays a muted gray and on emacs it produces black.
You can try a 256-color code like ^[[38;2;85;85;85m (which may also give inconsistent results for the reasons mentioned in #ThomasDickey's linked articles).

Reading a text file in color

I have a program that posts messages in different colors, eg: GREEN for info, RED for errors, YELLOW for warnings.
When I print them into a file, I see the codes for begin_color and end_color printed in ASCII.
Is there a text viewer (preferably in Linux) where I can render this codes to their appropriate colors ?

Vim on debian: cterm=bold doesn't work (using it over ssh with PuTTy as a client)

I've been trying to get colourschemes to work properly in VIM (on debian) when using it over ssh with PuTTy as a client (from windows7).
Such code from theme hi Search cterm=bold does not work - words are not bold.
I have tried a lot of themes - and I have found no themes with bold words (but using gvim on windows gives me bold words).
I'd appreciate any advice.
PuTTY by default represents bold as a brighter color, but you can change that at Change Settings > Window > Colours > [ ] Bolded text is a different colour. From the help:
Bolded text is a different colour
When the server sends a control sequence indicating that some text should be displayed in bold, PuTTY can handle this two ways. It can either change the font for a bold version, or use the same font in a brighter colour. This control lets you choose which.
By default the box is checked, so non-bold text is displayed in light grey and bold text is displayed in bright white (and similarly in other colours). If you uncheck the box, bold and non-bold text will be displayed in the same colour, and instead the font will change to indicate the difference.

Is there a wx Widget to show ANSI escape code colored text?

I can't seem to find a control that will display text colored with ANSI escape codes. For example:
"\e[0;32mHello \e[0;37mWorld"
Would display a green "Hello" and a white "World".
Does one exist?
I don't think that such a widget exists. You may look for some way of changing ANSI codes into HTML and then displaying it in wxWidgets. This may be useful:
http://code.activestate.com/recipes/577349-convert-a-transcript-with-ansi-escape-sequences-to/

Resources