GNU bug report logs -
#21711
tee: preserve isatty(). Goal: show colors to user.
Previous Next
Full log
View this message in rfc822 format
tag notabug
close 21711
stop
On 19/10/15 14:06, Thomas Güttler wrote:
> It would be great if tee would allow this:
>
> tee preserves isatty(), thus the caller thinks this
> is a real terminal and outputs ansi color codes.
>
> Tee displays the ansi colors on the screen. The output
> to the file gets filtered by tee (remove ansi color codes).
>
> I would make this optional since I guess the result will be
> only 99% equal to the old result.
>
> Example:
>
> git diff | tee --show-colors git.diff
>
> The user sees the color, and the file "git.diff" contains
> the output with the color codes removed.
>
> Related: http://superuser.com/questions/352697/preserve-colors-while-piping-to-tee
The options provided there are really all that is possible I think.
I.E. tell the command writing to the pipe, that it should consider it a terminal.
Since tee is "behind the pipe" it can't influence the writer to the pipe.
If you really want the color terminal codes in git.diff then you can:
git diff --color=always | tee git.diff
If you also want an appropriate pager:
git diff --color=always | tee git.diff | less -R
If you want just the diff without color codes in the file
then you can color easily after the fact with something like:
http://www.pixelbeat.org/scripts/idiff
git diff | tee git.diff | idiff
cheers,
Pádraig.
This bug report was last modified 9 years and 272 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.