2

printf "\033[1;32;40mGreen text on black background.\033[0m\n"

That is the green, but how can i get light green or other variation of color?

http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html , are only those color available for gnome-terminal as escape code?

Also how can i get bigger font with ruby?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
cola
  • 12,198
  • 36
  • 105
  • 165

4 Answers4

4

using the "1" as the first parameter, as you are doing already, that's as "light" a green as you're going to get. this guy's webpage might be helpful: http://www.linuxfocus.org/English/May2004/article335.shtml

testing on urxvt:

testing on urxvt not Gnome

[added later] there is a DEC extension for double-sized characters: Printing double-size characters with Ncurses but urxvt doesn't support it, I don't know about Gnome terminal.

Community
  • 1
  • 1
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
  • How can i get more brighter/light green?How can i get bigger font too? – cola Apr 19 '12 at 15:54
  • in an escape code? I don't believe it's possible using ANSI escapes. perhaps Gnome terminal has some extensions to ANSI but that's out of my expertise. – jcomeau_ictx Apr 19 '12 at 15:57
  • you only get two of each color, 31 through 37 (normal) and 1;31 through 1;37 (bold or bright) – jcomeau_ictx Apr 19 '12 at 15:59
  • hmm, I just noticed while testing that on urxvt, the bold colors actually use a larger font [nope, I was wrong, see new edit] – jcomeau_ictx Apr 19 '12 at 16:07
2

With an offset of 90 you can create bright/high contrast colors.

See here for a reference. Wikipedia mentions the bright color range, but doesn't really explain how to use them (if I haven't missed it).

If you combine it with the bold style you can create 4 variations of a color.

Example:

4 Shades of Blue

Joe23
  • 5,683
  • 3
  • 25
  • 23
0

It's a matter of the terminal support. The ansi codes that you list are interpreted by the terminal emulator and those codes are the only available colours (it comes from the days before windows and when 16 colours caused a stir).

If you need more you could consider using a graphical interface to your ruby app such as tk.

meesern
  • 2,518
  • 27
  • 29
  • How can i get bigger font too? – cola Apr 19 '12 at 15:55
  • using tk as he suggests, you can use any font and font size, but then you are creating a graphical user interface; you are no longer using a text terminal. – jcomeau_ictx Apr 19 '12 at 16:18
  • Then when i change the font size from gnome-terminal>Edit>Preference, how is it changed? Why can't i change the font size programmaticaly? – cola Apr 20 '12 at 12:16
  • perhaps Gnome terminal provides an API or some other "hooks" to change font and font size, or you could conceivably mimic the mouse movements and clicks necessary programmatically. for sure it can be done if you're willing to expend the time, research, and effort. – jcomeau_ictx Apr 23 '12 at 05:51
0

You can use an RGB escape code:

printf "\033[38;2;r;g;bmText\033[0m"

or, for background colour:

printf "\033[48;2;r;g;bmText\033[0m"

Just replace r, g, and b with the desired RGB value.