Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better ruby terminal coloring library

There are plenty of coloring libraries: colored, term-ansicolor. But is there any which can do this:

puts "#{'hello'.red} world!".bold

And world! should be bold.

To make it clear, I want to get this:

"\e[1m\e[31mhello\e[0m\e[1m world!\e[0m"

or better even this (just shorter):

"\e[1;31mhello\e[0;1m world!\e[0m"

instead of this:

"\e[1m\e[31mhello\e[0m world!\e[0m"
like image 721
tig Avatar asked Feb 25 '23 14:02

tig


1 Answers

As there is none, I wrote my own, with blackjack and hookers smart one — smart_colored

gem install smart_colored

and run

require 'smart_colored/extend'
# without extend you'll need to use 'string'.colored.red

puts "#{'hello'.red} world!".bold
like image 115
tig Avatar answered Mar 08 '23 01:03

tig