Hacker News new | ask | show | jobs
by jcw 5631 days ago
I've been using this zsh function for a year or two:

        jr () {
            echo "---"
            echo "\n##"`date +" %a %D %l:%M%P"` >> ~/journal.txt 
            cat >> ~/journal.txt
        }
It usually emits 72 dashes, so that I can stay within that margin (manually, heh). Edited to not break HN. The '##' is because I habitually markdown format everything.
2 comments

Mine is similar. My journal file is the hidden file ~/.journal and my script is in my home bin directory. It sets up a cat from STDIN, so I can just jot a few things down and ^D. I wanted something that would be as easy to use and non-intrusive as possible. And I used the %% on a line by themselves as the divider, as I also do in my Quotes_Aphorisms file, so scripts for searching and manipulating the fortune databases will also work on them.

  #!/bin/bash
  echo "%%" >> ~/.journal
  date +"%a %Y-%m-%d :: %X" >> ~/.journal
  cat - >> ~/.journal
That seems kind of unsafe to me, since it's all keeping it in one file.
How is it unsafe? (asking because I don't know, not to contradict)
One accidental command and every entry is lost, not just one entry or the most recent. Adding a "git commit journal.txt; git push offsite master" or something similar to your journal script will alleviate that risk.

Edit: you also don't have file timestamps to show when an entry was actually written, in case that matters to you.