News for hackers. Stuff that matters.
Re:Twitter's missing manual by waterhouse on Saturday February 27, 2016 @03:17AM (#11186512)
I used this for a long time:

  alias log='(date; cat) >>'

  ~> log file.txt
  Some log lines.
  Followed by a control-D.
  ^D
  ~> log file.txt
  And some more.
  ^D
  ~> 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.
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)

  function log
    set --local the_log $HOME/incomplete-logs/$argv[1]-(date "+%Y-%m-%d-%H%M%S")
    date >> $the_log
    rlwrap cat >> $the_log
    and cat $the_log >> $argv[1]
    and mv $the_log (dirname $the_log)/../completed-logs/
  end

There are no comments on this comment yet.