Forum: Ruby How to coloring Windows command prompt in irb?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A94d89bceafe0a9dfee54f8cb9bdc6f2?d=identicon&s=25 Shin guey Wong (sgwong)
on 2007-03-05 17:44
Is there any gem or ruby script to make irb command prompt in windows
color? I found a gem 'wirble' which is very nice but it only works in
Linux or Mac. It can't work in cygwin or windows command prompt. I
searching for hours on any windows command prompt which can show color
but couldn't make it, I only found some interactive python script to do

Finally I had to search for any source code to show color in cmd prompt.
In the end I found 2 win32api to do that and luckily I can quickly
included in ruby using the ruby win32api call. Here are the 2 win32api
to show color:

require 'Win32API'
get_std_handle ="kernel32", "GetStdHandle", ['L'], 'L')
set_console_txt_attrb ="kernel32","SetConsoleTextAttribute",
                        ['L','N'], 'I')
hout =,7)
puts 'default command prompt color',12)
puts 'command prompt red color text'

# the color range from 1 - 15 for black background color
# we also can change the input text color, I never try that, but I think
# it should be or -12....forgot already
This script is working fine for me to print color text. Can anyone
integrate this windows coloring script into 'wirble' ? It is hard for me
to change the 'wirble' ruby script. It would be thankfully if anyone can
do that.

Shin Guey
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jan Svitok (Guest)
on 2007-03-05 17:53
(Received via mailing list)
On 3/5/07, Shin guey Wong <> wrote:
> to show color:
> Regards,
> Shin Guey

maybe this would help: (ansi
coloring for console)
This topic is locked and can not be replied to.