aboutsummaryrefslogblamecommitdiffstats
path: root/_tj_openbsd
blob: e1f35363bab975c36d3974acc4265f9d06112f72 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                     








                                         
#!/usr/local/bin/bash

# Our target file
TODAY_JOURNAL=~/Notes/journal/$(date +\%Y-\%m-\%d).md

# Test whether it already exisits or not
if [[ -a $TODAY_JOURNAL ]]
then
    while read -r line
    do
        JLINE="- $(date +'%H:%M'): $line"
        echo "$JLINE" >> "$TODAY_JOURNAL"
    done < "${1:-/dev/stdin}"
else
    touch "$TODAY_JOURNAL"
    header_date="$(date +'%A %d %b %Y')"
    {   echo -e "# $header_date\n"
    } >> "$TODAY_JOURNAL"
    while read -r line
    do
        JLINE="- $(date +'%H:%M'): $line"
        echo "$JLINE" >> "$TODAY_JOURNAL"
    done < "${1:-/dev/stdin}"
fi