title: bash - color escapes codes
body: <p>I have a script that uses escape codes to highlight text matches in its output. All is good except when the output is piped to <code>less</code>, which prints the escape codes</p>
  
  <p>e.g.</p>
  
  <pre><code>$ echo -e "\033[31m -- Hello World! -- \033[m"
   -- Hello World! --
  </code></pre>
  
  <p>Piped to <code>less</code>:</p>
  
  <pre><code>$ echo -e "\033[31m -- Hello World! -- \033[m" | less
  ESC[31m -- Hello World! -- ESC[m
  </code></pre>
  
  <p>I was wondering how other tools like <code>ls</code>, <code>grep</code>, etc are able to output in color yet it looks fine when piped to <code>less</code>?</p>