Have you ever had the issue of skipping over Errors and Warnings in your terminal when directly looking at command outputs? This happened to me recently.
After seeking a way to avoid this in the future, I decided that a simple text highlighting would suffice. As it turns out, iTerm2 has several features that are specifically designed for such scenarios.
In your iTerm2 Profile settings (iTerm2 Preferences => Profiles) switch to Advanced and look for the Triggers section. Click Edit to add your own triggers. To solve my issue; we add a regular expression for the words we want to highlight.
Add the following regular expression to react on lines containing the text warn
Select Highlight Text as an action and customize the text color and background as needed.
Keep in mind that the flags are placed at the start of the regex. We use the case insensitive flag i in my example, so the regex starts with ?i:
After the colon, the regular expression begins.
You can either create multiple triggers or define multiple words in your pattern to highlight. The following example will highlight lines either containing the word error or fatal:
You can try out your regex on https://regex101.com/
If you don't like highlighting and would rather have your errors displayed in a separate output, iTerm2 can do that as well. To accomplish this, replace Highlight Text with Capture Output in the Trigger.