class String def colorize(color, options = {}) background = options[:background] || options[:bg] || false style = options[:style] offsets = ["gray","red", "green", "yellow", "blue", "magenta", "cyan","white"] styles = ["normal","bold","dark","italic","underline","xx","xx","underline","xx","strikethrough"] # xx = not defined start = background ? 40 : 30 color_code = start + (offsets.index(color) || 8) style_code = styles.index(style) || 0 "\e[#{style_code};#{color_code}m#{self}\e[0m" end end