How can i make the colorful font with black background for puts?

puts 'Hello World."

That prints ‘Hello World’ on white background with normal font size.
How can i make the font size bigger with black background and with green
font color like we can do in gnome-terminal from
Edit>Preferences>Colors.

Is it possible to change color of font and background color of terminal
with ruby?

http://rubyworks.github.com/ansi

Hi,

When working on Linux, ANSI escape codes are probably the most simple
(but also most lowlevel) way to do this:

http://en.wikipedia.org/wiki/ANSI_escape_code

There are also a lot of libraries floating around. The most extensive is
probably ncurses.

I’m trying to do ‘green font/texts on black background’.

printf “\033[40m\033[37mBlack Background\033[0m\n”

But that green is not brighter.
I’m trying to do something like,
http://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/

ESC-1, 32;40

How can i rewrite this printf “\033[40m\033[37mBlack
Background\033[0m\n” for escape one(1) ?

W dniu 19 kwietnia 2012 17:08 użytkownik gmspro gmspro
[email protected] napisał:

How can i rewrite this printf “\033[40m\033[37mBlack
Background\033[0m\n” for escape one(1) ?

These technique (ANSI escape codes) only work on Linux flavors. To
make it work on Windows, you need to run your Ruby script from inside
some better console than default cmd - I suggest ansicon (google it).

– Matma R.

Has anyone got this to work for (all) ruby output? Like in a bashrc or
something?
It’d be nice to have rake output, and the like, be escaped
automatically…

How can i set the text color to light green? Not the 32 only. I’m not
using windows, it’s linux.

I just read about grc today. Might try that.

On 04/19/2012 03:08 PM, gmspro gmspro wrote:

puts 'Hello World." That prints ‘Hello World’ on white background with
normal font size. How can i make the font size bigger with black
background and with green font color like we can do in gnome-terminal
from Edit>Preferences>Colors. Is it possible to change color of font
and background color of terminal with ruby?

$ gem install term-ansicolor

In your Ruby code:

require ‘term/ansicolor’

class String
include Term::ANSIColor
end

puts “Hello World”.green.on_black

More info: https://github.com/flori/term-ansicolor

On Thu, Apr 19, 2012 at 10:08 AM, gmspro gmspro [email protected]
wrote:

How can i rewrite this printf “\033[40m\033[37mBlack
Background\033[0m\n” for escape one(1) ?

puts “\033[40;37;1mBlack Background\033[0m”

Notes:

  • puts appends “\n” automatically
  • escape sequence “\033[1m” is used for bright (high intensity)
  • separate escape sequences can be combined by changing the trailing
    ‘m’ of all but the last one to ‘;’