GNU bug report logs - #21711
tee: preserve isatty(). Goal: show colors to user.

Previous Next

Package: coreutils;

Reported by: Thomas Güttler <guettliml <at> thomas-guettler.de>

Date: Mon, 19 Oct 2015 15:35:01 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21711 in the body.
You can then email your comments to 21711 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#21711; Package coreutils. (Mon, 19 Oct 2015 15:35:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thomas Güttler <guettliml <at> thomas-guettler.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 19 Oct 2015 15:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thomas Güttler <guettliml <at> thomas-guettler.de>
To: bug-coreutils <at> gnu.org
Subject: tee: preserve isatty(). Goal: show colors to user.
Date: Mon, 19 Oct 2015 15:06:42 +0200
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

Regards,
  Thomas Güttler




-- 
Thomas Guettler http://www.thomas-guettler.de/




Information forwarded to bug-coreutils <at> gnu.org:
bug#21711; Package coreutils. (Mon, 19 Oct 2015 16:06:02 GMT) Full text and rfc822 format available.

Message #8 received at 21711 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Thomas Güttler <guettliml <at> thomas-guettler.de>,
 21711 <at> debbugs.gnu.org
Subject: Re: bug#21711: tee: preserve isatty(). Goal: show colors to user.
Date: Mon, 19 Oct 2015 17:05:22 +0100
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.




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 19 Oct 2015 16:30:07 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 21711 <at> debbugs.gnu.org and Thomas Güttler <guettliml <at> thomas-guettler.de> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Mon, 19 Oct 2015 16:30:08 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 17 Nov 2015 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 271 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.