Highlight terminal output based on regex pattern #13641

Open
opened 2026-01-31 03:48:09 +00:00 by claunia · 0 comments
Owner

Originally created by @mikhail-naumenko on GitHub (Apr 27, 2021).

Description of the new feature/enhancement

That would be really handy to have an ability to apply some custom highlighting to terminal output.
For example when I read logs generated by some application I want to highlight particular feature name I'm interested in. So if logs of this feature start with Info: [Feature name] log message, I want to highlight "[Feature name]" with yellow.

That should be an ability to specify various highlighting rules. E.g. I have the following outputs
error: [feature 1] error message here
warning: [feature 2] some another message
info: [feature 3] yet another message

In this case I want to highlight "error:" with red, "warning:" with yellow, "info with green and "debug" with blue. And of course that would be cool if I highlight different features with different colors.

Just to emphasize. That is not mandatory that patterns are at the beginning of the string. It could be in any part of the string.

Proposed technical implementation details

A set of rules in settings.json which associate regex pattern with color. E.g.:

{
    "highlightRules": [
        "pattern": "^error:",
        "color": "red"
    ], [
        "pattern": "\[feature name\]",
        "color": "#deab1f"
    ], [
        "pattern" "^(?:\d{2,4}-?)+\s(?:\d{2,3}[:\.]?)+", // date pattern
        "color": "#34ebe1"
    ]
}
Originally created by @mikhail-naumenko on GitHub (Apr 27, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement That would be really handy to have an ability to apply some custom highlighting to terminal output. For example when I read logs generated by some application I want to highlight particular feature name I'm interested in. So if logs of this feature start with Info: [Feature name] log message, I want to highlight "[Feature name]" with yellow. That should be an ability to specify various highlighting rules. E.g. I have the following outputs error: [feature 1] error message here warning: [feature 2] some another message info: [feature 3] yet another message In this case I want to highlight "error:" with red, "warning:" with yellow, "info with green and "debug" with blue. And of course that would be cool if I highlight different features with different colors. Just to emphasize. That is not mandatory that patterns are at the beginning of the string. It could be in any part of the string. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation `details` A set of rules in `settings.json` which associate regex pattern with color. E.g.: ``` { "highlightRules": [ "pattern": "^error:", "color": "red" ], [ "pattern": "\[feature name\]", "color": "#deab1f" ], [ "pattern" "^(?:\d{2,4}-?)+\s(?:\d{2,3}[:\.]?)+", // date pattern "color": "#34ebe1" ] } ``` <!-- A clear and concise description of what you want to happen. -->
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 03:48:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13641