zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
20k stars 1.33k forks source link

Syntax highlighting Command Output Text #852

Closed Erik-Koning closed 2 years ago

Erik-Koning commented 2 years ago

It would be incredibly helpful to have the regex selection of a text output in terminal be able to be highlighted.

In the case of an output log steam, having any 'error' or 'warning' keywords highlighted would be helpful. Exmaple regex for finding 'error' in a commands output: 'error.*?([;\n$])'

Is this possible to achieve utilizing the code from this repo? How can we achieve this?

phy1729 commented 2 years ago

No, zsh-syntax-highlighting only handles the zsh command line. Command output does not pass through zsh at all. I'd recommend seeing if your terminal emulator has such a feature.

danielshahaf commented 2 years ago

For your specific use-case, just pipe to egrep --color '^|error'. You might need to add stdbuf(1) on the LHS of the pipe. For the general case, expect(1) might be a good place to start. Feel free to ask further on zsh-users@.