Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: coloring STDERR to terminal

On Tue, Jul 20, 2004 at 02:15:07PM -0700, Bart Schaefer wrote:
> What you're asking for is something to copy multiple inputs to a single 
> output, simultaneously adding characters (the color codes) to those inputs 
> yet without mixing the result any differently than it would have been 
> mixed if the writers of all those inputs had instead written directly to 
> that single output.
> This is, pretty much by definition, impossible, except (sometimes) at the 
> level of a kernel driver.

It's impossible with a single tty (or pty), but if stdout and stderr
each had their own pty, then a program could merge the two ptys to the
real terminal, coloring the stderr one.

Here's a link to a proof-of-concept C program that you can try out:


It spawns a shell and colors all the data sent to stderr.  I've only
tested it just a little bit, so I don't know if having a separate pty
for stderr will cause any weird problems or not.


Messages sorted by: Reverse Date, Date, Thread, Author