title: Piping an interactive session to a file
body: <p>I have made a toy interactive console program that is basically an interpreter:</p>
  
  <pre><code>$ myprogram
  &gt; this is user input
  this is program output
  </code></pre>
  
  <p>I want to pipe the full session, both user input and program output, into a log file. I can do this like so:</p>
  
  <pre><code>$ cat | tee &gt;(myprogram | tee -a file.log) &gt;&gt; file.log
  &gt; this is user input
  this is program output
  $ cat file.log
  &gt; this is user input
  this is program output
  </code></pre>
  
  <p>So the above session will display to the terminal as usual but will also be duplicated to the log file.</p>
  
  <p>Is there a better way to do this? I don't like how I have to write the log file twice, nor how I have to remember to wipe it before running this command.</p>