Colour highlighting output based on regex in shell

后端 未结 8 1916
鱼传尺愫
鱼传尺愫 2020-12-02 07:32

I\'d like to know if I can colour highlight the output of a shell command that matches certain strings.

For example, if I run myCommand, with the output below:

8条回答
  •  执笔经年
    2020-12-02 08:13

    You can use programs such as:

    • spc (Supercat)
    • grc (Generic Colouriser)
    • highlight
    • histring
    • pygmentize
    • grep --color

    You can do something like this, but the commands won't see a tty (some will refuse to run or behave differently or do weird things):

    exec > >(histring -fEi error)    # Bash
    

提交回复
热议问题