Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created October 6, 2011 03:00
Show Gist options
  • Save jordanorelli/1266386 to your computer and use it in GitHub Desktop.
Save jordanorelli/1266386 to your computer and use it in GitHub Desktop.
python color wrapping (adapted from Fabric)
def _mk_color_fn(code):
return lambda text, bold=False: \
'\033[%s%sm%s\033[0m' % (bold and '1;' or '', code, text)
_colormapping = {
'red': 31,
'green': 32,
'yellow': 33,
'blue': 34,
'magenta': 35,
'cyan': 36,
'white': 37
}
for k, v in _colormapping.items(): locals()[k] = _mk_color_fn(str(v))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment