k3color

This snippet will output colored text on a terminal:

from k3color import blue
from k3color import green
blue("blue") + " and " + green("green")
_images/colored-string.png

Working with prompt

To use colored string with terminal prompt, the terminal prompt is not wrapping correctly with very long commands. You need prompt=true to tell Str to fix these issues:

prompt = Str('colored prompt# ', color='red', prompt=True)

Those screenshots show this issue, the cursor is box.

prompt=False long command:

_images/colored-false-prompt.png

prompt=False long command after Home Key:

_images/colored-false-prompt-home-key.png

prompt=False long command after End Key:

_images/colored-false-prompt-end-key.png

prompt=True long command:

_images/colored-true-prompt.png

prompt=True long command after Home Key:

_images/colored-true-prompt-home-key.png

prompt=True long command after End Key:

_images/colored-true-prompt-end-key.png

Indices and tables