Add ANSI escape codes to a given string to print styled text in consoles and terminal emulators.
The main function with which about anything can be done is colored(). Almost any combination of font color, background color and different styles (highlighted, underlined, etc.) can be defined using keyword arguments.
For convenience, there exist some functions with an even shorter syntax: red(), green(), etc. to just color the text, hred(), hgreen(), etc. to get highlighted colored text, ured(), ugreen(), etc. to get underlined colored text. To just change the style of the text and not its color, the functions highlight(), underline(), invert(), conceal(), blink(), and normal() are provided.
List of colors: gray, red, green, yellow, blue, purple, cyan, lightgray
List of styles: normal, highlight, underline, blink, invert, conceal
Courtesy goes to: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
>>> highlight('Welcome to the ansicolor module')
Welcome to the ansicolor module
>>> red('This is some red text.')
This is some red text.
>>> ublue('And this is blue and underlined. Awesome!')
And this is blue and underlined. Awesome!
>>> hgray('Finished.')
Finished.
To see the results as rendered in your terminal emulator, call the test program by executing this module as a script:
python ansicolor/__init__.py
Add ANSI escape sequences to a given string to display it in a certain color and style in a console or terminal emulator. Also the background color bg can be set separately. If revert is True, return to normal style at the end of the string (default). In style, multiple comma-separated styles may be specified.
List of supported colors: gray, red, green, yellow, blue, purple, cyan, lightgray
List of supported styles: normal, highlight, underline, blink, invert, conceal
Test program to demonstrate the features of the ansicolor module.