Show HN: ch, a terminal tool to highlight specific words in your command output
4 weeks ago
1
A fast, simple terminal tool to highlight specific words in your command output with colors. Perfect for tailing logs, debugging, and making command output more readable.
Automatic color assignment from a preset palette
Custom hex colors for specific words
Case-insensitive matching by default
Whole word extension mode
Fast and efficient - designed for real-time log tailing
Cross-platform - works on macOS and Linux
ch reads from standard input line by line and:
Searches for specified words (case-insensitive by default)
Highlights matches with assigned colors
Handles overlapping matches (first match wins)
Outputs to standard output with ANSI color codes
The tool is optimized for streaming, making it ideal for real-time log monitoring.
ch [options] <word1><word2><word3> ...
Highlights specified words with colors from a preset palette.
Use custom hex colors (with or without # prefix) or named colors. Words without specified colors use preset colors.
Available named colors: red, green, orange, blue, pink, purple
-s - Case-sensitive matching (default is case-insensitive)
-w - Whole word extension - extends match until space or end of line
-b - Use background colors instead of foreground colors
# Only highlights exact case matchesecho"Error ERROR error"| ch -s Error
The -w flag extends the match to the entire word (until space or EOL):
# Input: "Notice: backup 13344 - started with name backup_13344.zip"echo"Notice: backup 13344 - started with name backup_13344.zip"| ch -w back
# Highlights: "backup" and "backup_13344.zip" (entire words)
The -b flag uses background colors instead of foreground colors:
# Mix preset, named, and hex colors
tail -f app.log | ch error::red warning::FF5500 info debug success::green
# Case-insensitive by default (highlights: error, Error, ERROR, ErRoR, etc.)
tail -f app.log | ch error
# Monitor web server logs with named colors
tail -f access.log | ch GET::blue POST::orange 404::red 500::red 200::green
# Clone or download the repository
git clone <repository-url>cd ch
# Initialize Go module
go mod init ch
# Build
go build -o ch
# (Optional) Install to your PATH
sudo mv ch /usr/local/bin/
ch uses buffered I/O and processes input line by line, making it efficient for:
Large log files
Real-time streaming with tail -f
High-throughput pipelines
Continuous monitoring scenarios
Go 1.16 or higher (for building)
Terminal with ANSI color support (most modern terminals)
macOS or Linux operating system
MIT License - feel free to use and modify as needed.