MCPcopy Index your code
hub / github.com/dalance/pipecolor

github.com/dalance/pipecolor @v0.4.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.4 ↗ · + Follow
24 symbols 45 edges 3 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pipecolor

A terminal filter to colorize output

Actions Status Crates.io codecov

Description

pipecolor is a terminal filter to colorize output. You can customize the colorize rule by regular expression.

Demo

demo

Install

Download from release page, and extract to the directory in PATH.

Alternatively you can install by cargo.

cargo install pipecolor

Put the colorize rule file to ~/.pipecolor.toml.

sample/pipecolor.toml in this repository is an example.

Usage

pipecolor can receive input through pipe, and colorize the output.

$ cat sample/access_log | pipecolor -c ./sample/pipecolor.toml

Filenames can be specified.

$ pipecolor -c ./sample/pipecolor.toml sample/maillog

If output is redirected to a file, colorization is disabled automatically. You can force to colorize by pipecolor --mode always.

Colorize rule

See the example rule sample/pipecolor.toml.

[[lines]]
    pat  = "^(.*?) .*? .*? \\[(.*?)\\] \".*?\" .*? .*? \".*?\" \"(.*?)\""
    colors = ["White", "LightGreen", "LightBlue", "Green"]
    [[lines.tokens]]
        pat   = "GET"
        colors = ["LightCyan"]
    [[lines.tokens]]
        pat   = "POST"
        colors = ["LightYellow"]
    [[lines.tokens]]
        pat   = "HEAD"
        colors = ["LightMagenta"]

lines.pat is a regular expression to specify colorize lines. If the expression is matched, the matched line is colorize to colors specified by lines.colors.

lines.colors is an array of colors, the first color is used to colorize the whole line. The rest colors are used to colorize the captured group in the expression. In the example, the whole line is colorized to White, the first group captured by (.*?) is colorized to LightGreen.

lines.tokens specifies the special tokens to be colorized in the matched line.

If no token is required, tokens can be empty list.

[[lines]]
    pat  = "^(.*?) .*? .*? \\[(.*?)\\] \".*?\" .*? .*? \".*?\" \"(.*?)\""
    colors = ["White", "LightGreen", "LightBlue", "Green"]
    tokens = []

Available colors

The available colors are below.

  • Black
  • Blue
  • Cyan
  • Default
  • Green
  • LightBlack
  • LightBlue
  • LightCyan
  • LightGreen
  • LightMagenta
  • LightRed
  • LightWhite
  • LightYellow
  • Magenta
  • Red
  • White
  • Yellow

Core symbols most depended-on inside this repo

colorize
called by 7
src/colorize.rs
run_opt
called by 7
src/main.rs
output
called by 3
src/main.rs
get_reader_file
called by 1
src/main.rs
get_reader_stdin
called by 1
src/main.rs
get_reader_proc
called by 1
src/main.rs
get_config_path
called by 1
src/main.rs
read_until_timeout
called by 1
src/read_timeout.rs

Shape

Function 19
Class 4
Enum 1

Languages

Rust100%

Modules by API surface

src/main.rs12 symbols
src/colorize.rs10 symbols
src/read_timeout.rs2 symbols

For agents

$ claude mcp add pipecolor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact