Console Output with Color using Ruby
Some times its really a good idea if some color could be added some output from CLI. Well ruby seems to do something like that with some code.
Here are some.
def look
print “33[32m Connecting”
h = sleep 1
puts “33[30m”
end
l = look
#STYLE = {
# :default => “33[0m”,
# # styles
# :bold => “33[1m”,
# :underline => “33[4m”,
# :blink => “33[5m”,
# :reverse => “33[7m”,
# :concealed => “33[8m”,
# # font colors
# :black => “33[30m”,
# :red => “33[31m”,
# :green => “33[32m”,
# :yellow => “33[33m”,
# :blue => “33[34m”,
# :magenta => “33[35m”,
# :cyan => “33[36m”,
# :white => “33[37m”,
# # background colors
# :on_black => “33[40m”,
# :on_red => “33[41m”,
# :on_green => “33[42m”,
# :on_yellow => “33[43m”,
# :on_blue => “33[44m”,
# :on_magenta => “33[45m”,
# :on_cyan => “33[46m”,
# :on_white => “33[47m” }
#
# The above code shows some ruby coloring for the various text.
About this entry
You’re currently reading “Console Output with Color using Ruby,” an entry on Connecting the dots
- Published:
- 2.6.08 / 10am
- Category:
- filla
- Tags:
- benjamin baka, color text, console text color, ruby
No comments
Jump to comment form | comments rss [?] | trackback uri [?]