-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrite_daylog.sh
30 lines (27 loc) · 1.01 KB
/
write_daylog.sh
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
26
27
28
29
30
# daylog opener
# run this at startup to have notes ready
FILE=~/Notes/01-log/$(date +%Y)-$(date +%m)_DAYLOG.md
MONTH=$(date '+%Y-%m')
DATE=$(date '+%a %Y-%m-%d %l:%M %P')
echo "$FILE"
if test -f "$FILE"; then
echo "$FILE exists."
sed -i "6i $DATE" $FILE
sed -i '7i --------------------------------------------------------------------------------\n\n\n' $FILE
code -g $FILE:9
else
echo "$FILE does not exist."
echo "creating file..."
echo "---" >> $FILE
echo "title: \"Log for $(date +%B), $(date +%Y)\"" >> $FILE
echo "date: $(date +%Y)-$(date +%m)" >> $FILE
echo "tags: log, periodic, periodic/monthly" >> $FILE
# link to next and previous months using this: https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html
echo "---" >> $FILE
echo >> $FILE
echo >> $FILE
echo "$DATE" >> $FILE
echo "--------------------------------------------------------------------------------" >> $FILE
echo >> $FILE
code -g $FILE:10
fi