title: Bash: how to highlight executed commands?
body: <p>Bash provides option <code>-v</code> <code>--verbose</code> which writes the command as it read to stderr.<br>
  Need to highlight this output. 
  Current solution </p>
  
  <pre><code>bash -v script 2&gt; &gt;(sed $'s,.*,\e[38;5;123m&amp;\e[m,' &gt;&amp;2)
  </code></pre>
  
  <p>highlight everything in stderr.</p>
  
  <p>So the problem is to separate <code>-v</code> output from others stderr.</p>
  
  <p>Addition.
  bash has <code>BASH_XTRACEFD</code> which can be used to highlight <code>-x</code>(xtrace) output.</p>
  
  <p>Update: such kind of redirection also violates sequence of command/response - responses can appear before commands.<br>
  So the current solution is DO NOT highlight nothing at all.</p>
  
  <p>Upd2.: It looks to be a good idea to use <code>expect</code> - programmed dialogue with interactive programs..</p>