/color

Colorize output of shell commands

Primary LanguageGoMIT LicenseMIT

color

pkg.go.dev documentation License: MIT Go Report Card

Color is a small CLI application which provides the ability style text from the standard input.

Installation

To build use:

git clone https://github.com/adrg/color.git
cd color
make

To install system wide use:

sudo make install

To uninstall use:

sudo make uninstall

Usage

input | color [-h] [-v] STYLE...

Input format

Parameters can be specified in the input text with '{index}' where index is a positive number less than the number of styles passed in to color. Parameter indices can be repeated. To reset the current style use '{r}'. A reset is automatically applied before each parameter occurence in the input text. The last '{r}' in the can be omitted as a reset is done at the end of the input.

Style format

foreground:background+attributes

Colors

black red green yellow blue magenta cyan white

Attributes

b - Bold
d - Dim
i - Italic
u - Underline
B - Blink
f - Fast blink
r - Reverse
h - Hidden
c - Crossed out

Examples

echo "{0}green fg" | color green
echo "{0}blue bg{r}, default bg" | color :blue
echo "{0}yellow fg{r}, default fg, {0}yellow fg again" | color yellow
echo "{0}green fg, red bg, bold" | color green:red+b
echo "{0}underline{r}, {1}bold{r} and {2}reverse" | color +u +b +r
echo "{0}blue fg, red bg, bold, reverse" | color blue:red+br

screenshot

Contributing

Contributions in the form of pull requests, issues or just general feedback, are always welcome.
See CONTRIBUTING.MD.

License

Copyright (c) 2014 Adrian-George Bostan.

This project is licensed under the MIT license. See LICENSE for more details.