NullVoxPopuli
NullVoxPopuli

Reputation: 65173

How do I print / puts with color?

Like in the cucumber tests, there are color-coded outputs... how do I do that?

Upvotes: 3

Views: 2739

Answers (3)

Anderson Rodrigues
Anderson Rodrigues

Reputation: 633

puts "\e[0;31m your text here \e[0m\n"

Upvotes: 0

Nuno Gonçalves
Nuno Gonçalves

Reputation: 6805

I'm not sure this is from any gem I have, but doing thig will result in purple output.

puts "\e[0;35m this is a purple text \e[0m\n"

Upvotes: 2

Govan
Govan

Reputation: 923

Do you mean in the context of irb? If so, I'd suggest Wirble to colourize your output.

Upvotes: 2

Related Questions