title: Automatically capture all stderr and stdout to a file and still show on console
body: <p>I'm looking for a way to capture all standard output and standard error to a file, while also outputting it to console. So:</p>
  
  <pre><code>(set it up here)
  set -x # I want to capture every line that's executed too
  cat 'foo'
  echo 'bar'
  </code></pre>
  
  <p>Now the output from foo and bar, as well as the debugging output from set -x, will be logged to some log file and shown on the console.</p>
  
  <p>I can't control how the file is invoked, so it needs to be set up at the start of the file.</p>