Is it possible to make stdout and stderr output be of different colors in XTerm or Konsole?

前端 未结 7 620
抹茶落季
抹茶落季 2021-01-30 17:16

Is it even achievable?

I would like the output from a command’s stderr to be rendered in a different color than stdout (for example, in red).

I ne

7条回答
  •  北海茫月
    2021-01-30 17:32

    I can't see that there is any way for the terminal emulator to do this.

    The interface between the terminal emulator and the shell/app is via a pseudo-tty, where the terminal emulator is on the master side and the shell/app on the other. The shell/app have both stdout and stderr connected to the same pty, so when the terminal emulator reads from the pty for the shell/app output it can no longer tell which was written to stdout and which to stderr.

    You will have to use one of the solutions that intercepts the data between the application and the slave-pty and inserts escape codes to control the terminal output colo(u)r.

提交回复
热议问题