dtonon/ch
{ "createdAt": "2025-10-13T09:47:30Z", "defaultBranch": "master", "description": "Colored Highlighter - A fast, simple terminal tool to highlight specific words in your command output with colors", "fullName": "dtonon/ch", "homepage": null, "language": "Go", "name": "ch", "pushedAt": "2025-10-16T11:40:21Z", "stargazersCount": 131, "topics": [], "updatedAt": "2025-12-26T17:05:12Z", "url": "https://github.com/dtonon/ch"}ch - Colored Highlighter
Section titled “ch - Colored Highlighter”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.
![]!(screenshot.png)
Features
Section titled “Features”- Automatic color assignment from a preset palette
- Custom hex colors for specific words
- Optiona discreet sound on match
- 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
How It Works
Section titled “How It Works”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 preset colors use a pastel palette optimized for readability on both light and dark terminals: Red, Green, Orange, Blue, Pink, Purple.
Colors cycle when you have more than 6 words without custom colors.
The tool is optimized for streaming, making it ideal for real-time log monitoring.
Basic syntax
Section titled “Basic syntax”ch [options] <word1> <word2> <word3> ...Highlights specified words with colors from a preset palette.
Custom colors
Section titled “Custom colors”ch <word1>::<HEXCOLOR> <word2>::<COLORNAME> <word3> ...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
Options
Section titled “Options”-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-a- Play a discreet beep when a match is found
Case-sensitive matching
Section titled “Case-sensitive matching”# Only highlights exact case matchesecho "Error ERROR error" | ch -s ErrorWhole word extension
Section titled “Whole word extension”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)Background colors
Section titled “Background colors”The -b flag uses background colors instead of foreground colors:
# Highlight with background colorstail -f app.log | ch -b error warning success
# Mix with custom colorstail -f app.log | ch -b error::red warning::orange info::blueAudible alert
Section titled “Audible alert”The -a flag plays a discreet beep when a match is found; the alert is not even if matches are frequent (max one every 5 seconds):
# Play a beeptail -f app.log | ch -a panic::red# Test repeated match heads with a one-second intervalfor i in {1..10}; do echo "line $i"; sleep 1; echo "error occurred"; sleep 1; done | ch -a errorExamples
Section titled “Examples”Log monitoring
Section titled “Log monitoring”# Tail a log file with highlighted keywordstail -f app.log | ch error warning success
# Highlight with custom colors (hex and named)tail -f app.log | ch error::red warning::orange info::00FF00
# Monitor system logsjournalctl -f | ch failed::red error::red success::green started::blue
# Watch Docker logsdocker logs -f container_name | ch error warning started stopped
# Monitor Kubernetes podskubectl logs -f pod-name | ch error panic fatal warningDatabase and queries
Section titled “Database and queries”# Highlight database queriestail -f query.log | ch SELECT INSERT UPDATE DELETE
# Database monitoringmysql -e "SHOW PROCESSLIST;" | ch SELECT UPDATE DELETE INSERTDevelopment and debugging
Section titled “Development and debugging”# Search and highlightgrep -i "error" app.log | ch error exception failed
# Highlight build outputmake 2>&1 | ch error warning success completed
# Git log highlightinggit log --oneline | ch feat fix docs style refactor
# Highlight code patternscat script.sh | ch function if else errorCombining features
Section titled “Combining features”# Mix preset, named, and hex colorstail -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 colorstail -f access.log | ch GET::blue POST::orange 404::red 500::red 200::greenFrom source
Section titled “From source”# Clone or download the repositorygit clone <repository-url>cd ch
# Initialize Go modulego mod init ch
# Buildgo build -o ch
# (Optional) Install to your PATHsudo mv ch /usr/local/bin/Buffering issues
Section titled “Buffering issues”Some programs detect when their output is being piped and switch from line buffering to full buffering for performance. This means output may not appear in real-time when using ch. If you experience delayed highlighting or no output until the program completes, you need to force line buffering using one of these methods:
# Use script (built-in)script -q /dev/null your-command | ch your-words
# Or install and use unbufferbrew install expectunbuffer your-command | ch your-words# Use stdbuf (usually built-in)stdbuf -oL your-command | ch your-words
# Or use scriptscript -qfc "your-command" /dev/null | ch your-words
# Or install and use unbufferunbuffer your-command | ch your-wordsPerformance
Section titled “Performance”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
Requirements
Section titled “Requirements”- Go 1.16 or higher (for building)
- Terminal with ANSI color support (most modern terminals)
- macOS or Linux operating system
License
Section titled “License”MIT License - feel free to use and modify as needed.