14

Is it possible to configure the terminal in OS X to show stderr output automatically in a different colour than stdout output from a process?

Or is this only possible if the process is outputting coloured output?

3
  • Sadly, as of 2019 the correct answer is this is no longer possible. Both hilite and stderred are unmaintained and broken and I am still looking for a workaround.
    – sorin
    Sep 30 '19 at 15:34
  • @sorin I just installed hilite via Homebrew, it still works as expected (would be surprised if not actually, it uses very basic functionality to accomplish its task).
    – nohillside
    Sep 30 '19 at 16:01
  • @sorin stderred may not work any longer as it seems to change the location dynamic libraries are loaded from, which may be prevented by SIP nowaydays
    – nohillside
    Sep 30 '19 at 16:02
10

There is no straightforward solution, but there are at least a few workarounds available to do this.

  • You can install hilite by building the single C file (hilite.c in this case) or by using brew install hilite (with homebrew installed on the system). Use it as hilite <command>.

  • You can use the command from this answer on serverfault (substitute command with the name of your script/command) to make stderr appear in red (for other colors, refer the ANSI escape sequences list and change the 31m in the below command accordingly):

    command 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done)
    
  • You can use stderred to color stderr in red.

0
3

You may want to have a look at stderred which allows to output Stderr in red.

It's OSX compatible and there is a manual to install it on OSX.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .