Please note

This version of Fabric is outdated. If you're looking for the latest stable release, please click here.

Color output functions

New in version 0.9.2.

Functions for wrapping strings in ANSI color codes.

Each function within this module returns the input string text, wrapped with ANSI color codes for the appropriate color.

For example, to print some text as green on supporting terminals:

from fabric.colors import green

print(green("This text is green!"))

Because these functions simply return modified strings, you can nest them:

from fabric.colors import red, green

print(red("This sentence is red, except for " + green("these words, which are green") + "."))

If bold is set to True, the ANSI flag for bolding will be flipped on for that particular invocation, which usually shows up as a bold or brighter version of the original color on most terminals.

fabric.colors.blue(text, bold=False)
fabric.colors.cyan(text, bold=False)
fabric.colors.green(text, bold=False)
fabric.colors.magenta(text, bold=False)
fabric.colors.red(text, bold=False)
fabric.colors.white(text, bold=False)
fabric.colors.yellow(text, bold=False)

Previous topic

SSH behavior

Next topic

Context Managers

This Page