I used this for a long time:<p><pre><code>  alias log=&#x27;(date; cat) &gt;&gt;&#x27;

  ~&gt; log file.txt
  Some log lines.
  Followed by a control-D.
  ^D
  ~&gt; log file.txt
  And some more.
  ^D
  ~&gt; cat file.txt 
  Sat Feb 27 00:16:49 PST 2016
  Some log lines.
  Followed by a control-D.
  Sat Feb 27 00:17:04 PST 2016
  And some more.
</code></pre>
But then I wanted to be able to write to the same logfile from a few terminals at once without interleaving the lines, so: (fish syntax)<p><pre><code>  function log
    set --local the_log $HOME&#x2F;incomplete-logs&#x2F;$argv[1]-(date &quot;+%Y-%m-%d-%H%M%S&quot;)
    date &gt;&gt; $the_log
    rlwrap cat &gt;&gt; $the_log
    and cat $the_log &gt;&gt; $argv[1]
    and mv $the_log (dirname $the_log)&#x2F;..&#x2F;completed-logs&#x2F;
  end</code></pre>