simplecolor

Description

A simple library for coloring text output. Heavily inspired by rainbow, term-ansicolor and paint.

By default this gem does not change the String class, unlike rainbow. The reason I wrote this gem is that when mixed in String it only adds two methods: color and uncolor. This is the main reason I don't use term-ansicolor which is more powerful, but adds more methods when mixed in. The gem paint is similar to this one, but with more powerful shortcuts definitions.

Features

Examples

~~~ ruby require 'simplecolor'

SimpleColor.color(“blue”, :blue, :bold) SimpleColor.color(:blue,:bold) { “blue” } SimpleColor.color(:blue,:bold) << “blue” << SimpleColor.color(:clear)

SimpleColor.mix_in_string “blue”.color(:blue,:bold) “e[34me[1mbluee[0m”.uncolor ~~~

Usage

There is a global switch SimpleColor.enabled to select the color mode. The possible values are

When using a color escape sequence in a prompt in zsh, zsh will count the escape sequences as part of the length of a prompt. To mark them as non printable, one has to wrap them around %{ and %}. With SimpleColor.enabled=:shell this is done automatically by SimpleColor.

Requirements

None.

Install

<s>~ sh $ gem install simplecolor </s>~

This installs v0.3.0, the current master version may not work.

When installing from git, you can regenerate the list of color names by running data/rgb_colors.rb.

TODO

Copyright © 2013–2020 Damien Robert

MIT License. See LICENSE.txt for details.