A fast, Rust-based command-line tool that colorizes the output of other commands using regex-based rules. Drop-in replacement for grc with better performance.
Shell (curl):
curl -sS https://raw.githubusercontent.com/lazywalker/rgrc/master/script/install.sh | sh
Cargo:
cargo install rgrc
Homebrew:
brew tap lazywalker/rgrc
brew install rgrc
Arch Linux:
yay -S rgrc
# Colorize any command
rgrc ping -c 4 google.com
rgrc docker ps
rgrc df -h
# Set up aliases (recommended)
echo 'eval "$(rgrc --aliases)"' >> ~/.bashrc
source ~/.bashrc
# Then use commands directly
ping -c 4 google.com # automatically colorized
docker ps # automatically colorized
System: df, free, ps, top, vmstat, iostat, uptime, mount
Network: ping, traceroute, netstat, ss, ip, curl, dig
Development: gcc, make, docker, kubectl, git, mvn, go
Files: ls, find, du, fdisk, lsof, stat
See full list in share/ directory
rgrc [OPTIONS] COMMAND [ARGS...]
--color=on|off|auto Control color output (default: auto)
--aliases Generate shell aliases
--all-aliases Generate all aliases
--except=CMD,... Exclude commands from aliases
--completions SHELL Print completion script (bash|zsh|fish|ash)
--version, -v Show version
--help, -h Show help
Create ~/.config/rgrc/conf.mycommand:
regexp=^ERROR
colours=red,bold
regexp=^WARNING
colours=yellow
regexp=^INFO
colours=green
Add to ~/.rgrc:
mycommand
conf.mycommand
# Bash
rgrc --completions bash > /etc/bash_completion.d/rgrc
# Zsh
rgrc --completions zsh > ~/.zfunc/_rgrc
# Fish
rgrc --completions fish > ~/.config/fish/completions/rgrc.fish
# Match only once per line
regexp=^\s*#
colours=cyan
count=once
# Replace matched text (with backreferences)
regexp=(ERROR|WARN|INFO)
colours=red,yellow,green
replace=[\1]
# Stop processing after match
regexp=^FATAL
colours=red,bold
count=stop
Count options: once, more (default), stop
Replace: Supports \1, \2, etc.
# Build
cargo build --release
# Test
cargo test
# Test with fancy-regex
cargo test --features=fancy
# Install locally
make release && sudo make install
rgrc uses a hybrid regex approach for optimal performance:
regex crate (~2-5x faster)--features=fancy (default): Battle-tested fancy-regex
| Binary: ~2.1MB | Supports: backreferences, variable-length lookbehind |
EnhancedRegex
| Binary: ~1.8MB | Supports: fixed-length lookahead/lookbehind |
Core dependencies (when built without fancy feature):
regex: Standard regex enginemimalloc: Fast memory allocatorOptional:
fancy-regex: Enhanced regex with advanced features (enabled by default)MIT - see LICENSE for details.
Inspired by grc by Radovan GarabĂk and grc-rs by Lars Christensen.