Crates.io | recolor |
lib.rs | recolor |
version | 0.1.0 |
source | src |
created_at | 2023-07-08 16:15:52.410556 |
updated_at | 2023-07-08 16:15:52.410556 |
description | Recolor any command output |
homepage | |
repository | https://github.com/samwho/recolor |
max_upload_size | |
id | 911550 |
size | 32,580 |
recolor
is a tool to help you colourise the output of any command. It works
using familiar regular expressions, and gives you lots of flexibility and
control in what the output looks like.
recolor
reads input line by line and applies the regular expression you
specify to each line. It colours capture groups only, and if you name your
capture groups you can customise the colours used.
As an example, the following will colour only the 2nd octet of any IPv4
addresses output by ping
:
$ ping google.com | recolor "\d{1,3}\.(\d{1,3})\.\d{1,3}\.\d{1,3}"
We could colour all 4 octets separately, recolor
has a set of default
colours it cycles through each new capture group:
If we wanted to control the styling, we can name our capture groups and specify the styling after the regex.
$ ping google.com | recolor "(?P<one>\d{1,3})\.(?P<two>\d{1,3})\.(?P<three>\d{1,3})\.(?P<four>\d{1,3})" one=red,bold two=green,underline three=yellow,dim four=black
No, and I don't have plans to. It would make the code significantly more complicated. If it's something you really, really want I would happily review a PR, though.
Here's a list of all of the words you can use as styles:
black
red
green
yellow
blue
magenta
cyan
white
bright_black
bright_red
bright_green
bright_yellow
bright_blue
bright_magenta
bright_cyan
bright_white
bold | bolded
dimmed | dim
italic | italics
underline | underlined
blink | blinking
hidden
strikethrough | struckthrough | strike
You can also specify colours as CSS style hex values, e.g. #ff0000
for red.