Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: TRAPDEBUG vs zsh -x
On Wed, Apr 20, 2022 at 12:46 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> When using "zsh -x", we see all of the lines after they've been fully evaluated, but there's no way to add syntax highlighting sugar to these lines.
If you have a colorizing program that you want to use, you can do
# Silly example of colorizing
alias colorizing="grep --color '[A-Z]'"
exec 2>>(colorizing)
and the xtrace output will go through that.
> Are there any TRAPXXX functions which are passed the same text as "zsh -x" will emit (sans the $PS4 expansion).
No, there aren't.
You could play around with variations on this hack:
unsetopt DEBUG_BEFORE_CMD
PS4=
emulate zsh +x -c 'exec {stderr}>&2
preexec() {
integer in_preexec=1
exec 2>>(colorizing)
}
TRAPDEBUG() {
((in_preexec)) || exec 2>>$stderr
}'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author