aboutsummaryrefslogtreecommitdiffstats
path: root/_tj
blob: 469c4cb1aa347dc872ee494323c640c528d69618 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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 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 line
    do
        JLINE="- $(date +'%H:%M'): $line"
        echo $JLINE >> "$TODAY_JOURNAL"
    done < "${1:-/dev/stdin}"
fi