| Crates.io | highlite |
| lib.rs | highlite |
| version | 0.1.5 |
| created_at | 2025-12-29 12:01:07.090842+00 |
| updated_at | 2025-12-30 12:21:13.466445+00 |
| description | A fast, rule-based CLI highlighter for stdin and files. |
| homepage | |
| repository | https://github.com/sakimidare/highlite |
| max_upload_size | |
| id | 2010500 |
| size | 93,653 |
highlite is a fast, rule-based CLI highlighter for stdin and files, written in Rust.
It reads text line by line and highlights matches using ANSI colors, making it suitable for large files, streaming input, and Unix-style pipelines.
--follow-journal to follow system logs
--follow-file <FILE> to follow a file like tail -f
cargo install highlite
git clone https://github.com/sakimidare/highlite.git
cd highlite
cargo build --release
CLi Options:
| Option | Description |
|---|---|
-i, --ignore-case |
Force all rules to match case-insensitively |
-f, --file <FILE> |
Input file (defaults to stdin) |
-c, --config <CONFIG> |
Path to YAML config file (optional) |
-p, --preset <PRESET> |
Use a built-in preset (logs, cpp, json) |
--follow-journal |
Follow system journal logs (journalctl -f) |
--follow-file <FILE> |
Follow a file like tail -f |
-h, --help |
Show help message |
Highlight stdin:
cat examples/logs/example_cpp.cpp | highlite --config examples/rules/cpp_rules.yaml
Highlight a file:
highlite --config examples/rules/log_rules.yaml --file examples/logs/example_log.log
Force case-insensitive matching for all rules:
highlite --config examples/rules/cpp_rules.yaml --ignore-case < examples/logs/example_cpp.cpp
Use a built-in preset
highlite --preset logs --file examples/logs/example_log.log
Follow system journal in real-time
highlite --preset logs --follow-journal
Follow a specific file in real-time (like tail -f)
highlite --preset cpp --follow-file examples/logs/example_cpp.cpp
NOTE:
--follow-... has a higher priority than --file.
If stdin is a TTY, highlite will wait for input until EOF is received.
Instead of providing a YAML configuration file, you can use one of the built-in presets:
logs – common log highlightingcpp – C++ syntax highlightingjson – JSON highlightingExample:
highlite --preset cpp --file examples/logs/example_cpp.cpp
The configuration file is written in YAML.
include:
- common_optional.yaml
rules:
- keyword: "TODO"
color: { name: Yellow }
ignore_case: true
- keyword: "//.*|/\\*.*\\*/"
is_regex: true
ignore_case: false
color: { r: 106, g: 153, b: 85 }
Each rule has the following fields:
keyword
The keyword or regular expression to match.
is_regex (optional, default: false)
Whether keyword should be treated as a regular expression.
ignore_case (optional, default: false)
Whether this rule should match text case-insensitively.
Note:
If the CLI flag --ignore-case is provided, all rules will be treated as
case-insensitive, regardless of this setting.
color
The highlight color, either a preset name or an RGB value.
color: { name: Red }
color: { name: Yellow }
color: { name: Blue }
color: { name: Green }
color: { name: Cyan }
color: { name: Magenta }
color: { r: 106, g: 153, b: 85 }
See examples/logs for log highlighting examples.
See examples/rules for YAML configuration examples.
All rules are merged into a single regular expression.
Each rule corresponds to a named capture group.
Case sensitivity is handled per rule using inline regex flags.
Highlighting is performed in a single pass per line.
Output buffers are reused to minimize allocations.
This design keeps the implementation simple while maintaining high performance.
No nested highlighting (for example, comments inside strings).
No cross-line strings or comments (for example: multiline /* */).
No language-aware parsing; matching is purely regex-based.
ANSI color output requires a compatible terminal.
This project is licensed under the GNU General Public License v3.0.
Issues and pull requests are welcome.