- # http://travelingfrontiers.wordpress.com/2010/08/22/how-to-add-colors-to-linux-command-line-output/
- def color_text(text, color, bold = false)
- colors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
- if $stdout.isatty && colors.include?(color.to_sym)
- format("\033[%d;%dm%s\033[0m", (bold ? 1 : 0), colors.index(color.to_sym)+30, text)
- else
- text
- end
- end