Globally Coloring the Terminal by Regex
Short version is: why, yes, you can pipe output from the shell, like any other program.
From there, you can use whatever you like, like, say
$ bash | sed "$(echo -e "s@dog@\e[31mdog\e[0m@g; s@more here@more here@g;")"
Thought I'd add my 'rainbow'. Enjoy:
for((b=0;$b<8;b++)); do echo -ne "\e[4${b}m4$b : "; \
for((f=0;$f<8;f++)); do echo -ne "\e[3${f}m3${f}"; done; echo -e "\e[0m"; done
I'm still looking for a linux terminal emulator with this feature, but for those reading this who are on macOS X:
- Get iTerm2 (you'll want this anyway if you're doing lots of command line work on OS X), go to "Settings > Profiles > Advanced" and then click "Edit" under "Triggers". There you can add a trigger with a regular expression like
^.*\[ERROR\].*$
and set the action to "Highlight text" and the parameter to something like "Red foreground".