zsh-users
 help / color / mirror / code / Atom feed
From: Thorsten Kampe <thorsten@thorstenkampe.de>
To: zsh-users@zsh.org
Subject: Re: How to redirect output without escape sequences to a file
Date: Mon, 16 May 2011 13:03:14 +0200	[thread overview]
Message-ID: <iqr0a0$f92$2@dough.gmane.org> (raw)
In-Reply-To: <110509080130.ZM19360@torch.brasslantern.com>

* Bart Schaefer (Mon, 09 May 2011 08:01:30 -0700)
> On May 8,  9:27pm, Thorsten Kampe wrote:
> } I've modified my PS4 so it contains a little bit of colour[1].
> 
> I was going to suggest that you stop using the terminal escape
> sequences directly and use the %F prompt escape instead:
> 
>     PS4='%F{cyan}%B+%b%f%1N[%i]%F{cyan}%B:%b%f '
> 
> Theoretically, these are only supposed to be output if the terminal
> supports them, so I thought that setting TERM=dumb would then turn
> off the coloring.  But no ... zsh goes for ANSI sequences if the
> terminal definition doesn't specify, so something is always output.
> 
> } Is there a way to either strip the escape sequences when redirected to
> } a file or to modify PS4 when stderr is redirected to a file?
> 
> So, the alternative is to do the stripping.  Instead of
> 
>     ... >& trace.log
> 
> use 
> 
>     ... 2>>(col > trace.log) >&2
> 
> Yes, that's somewhat inconvenient.

...and somehow not working (form me). I still got (stripped) color stuff 
in the output file ("1m33m-0m39m service:directory-agent" for instance).

"| sed 's/\x1b\[[0-9]\{1,2\}m//g'" worked for me.

How would the command line look like if wanted to pipe stdout and stderr 
to sed, and then redirect both to trace.log?

Thorsten


  parent reply	other threads:[~2011-05-16 11:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-08 19:27 Thorsten Kampe
2011-05-09  1:58 ` Aaron Davies
2011-05-09 15:01 ` Bart Schaefer
2011-05-12 18:10   ` Thorsten Kampe
2011-05-13  6:32     ` Bart Schaefer
2011-05-16 11:03   ` Thorsten Kampe [this message]
2011-05-16 21:36     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='iqr0a0$f92$2@dough.gmane.org' \
    --to=thorsten@thorstenkampe.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).