With the option
set -x
, each command is echoed to STDERR before execution, prefixed by the expanded $PS4
, with the first character being repeated according to the call stack depth.
I want the output of the $PS4
prompt to be colorized. I.e. where
(set -x; ls -l)
will currently print
+ ls -l
I want an output
\033[90m+ ls -l\033[0m
\ \
\ `- Reset color
`- Muted gray
However, with PS4 being printed before echoing the command, I can't think of a method to reset the color with \033[0m
*before* the command is executed.
Is it possible to do this somehow?
Asked by kdb
(229 rep)
Oct 14, 2019, 10:55 AM