Skip to content

vishaltelangre/term-colorizer

Repository files navigation

Term::Colorizer

Gem Version Build Status

Print colorized strings on terminal (Useful for printing fancy logs)

Installation

Install gem by using following command:

gem install term-colorizer

or add it to your Gemfile as:

gem 'term-colorizer', require: 'term-colorizer'

Usage

"Duck can quack".green
# => "\e[32mDuck can quack\e[0m"

puts "Wow, that's really".underline + " cool ".black.strikethrough + "hot!".bg_red.bright_yellow
# guess what it will do?

To see all accessible methods provided by term-colorizer, use:

>> "Hello".term_colorizer_methods
=> [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :bright_black, :bright_red, :bright_green, :bright_yellow, :bright_blue, :bright_magenta, :bright_cyan, :bright_white, :bg_black, :bg_red, :bg_green, :bg_yellow, :bg_blue, :bg_magenta, :bg_cyan, :bg_white, :underline, :strikethrough, :term_colorizer_methods, :fancy_color_methods, :no_underline, :no_strikethrough, :no_color, :no_bg_color, :plain_text, :reset_fancyness]

To see available color methods only:

>> "Hello".color_methods
=> [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]

To see available bright (bold) color methods only:

>> "Hello".bright_color_methods
=> [:bright_black, :bright_red, :bright_green, :bright_yellow, :bright_blue, :bright_magenta, :bright_cyan, :bright_white]

To see available background color methods only:

>> "Hello".bg_color_methods
=> [:bg_black, :bg_red, :bg_green, :bg_yellow, :bg_blue, :bg_magenta, :bg_cyan, :bg_white]

Screenshots

term-colorizer-screenshot-1!

And, for sake -- also added bunch of reset methods, viz. plain_text, reset_fancyness, no_color, no_bg_color, no_underline, no_strikethrough. You can use 'em as:

>> "That's it, boy!".green.bg_yellow.plain_text
=> "That's it, boy!"

term-colorizer-screenshot-2!

😋

Contributing

You're encouraged to contribute to this gem.

  • Fork this project.
  • Make changes, write tests.
  • Report bugs, comment on and close open issues.
  • Updated CHANGELOG.
  • Make a pull request, bonus points for topic branches.

Copyright and License

Copyright (c) 2013, Vishal Telangre and Contributors. All Rights Reserved.

This project is licenced under the MIT License.

About

Print colorized strings on terminal (Useful for printing fancy logs)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages