From 8fe6ac015a2e12f71886f3eadbe558af2f054be7 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 23 Feb 2023 17:01:38 +0800 Subject: Update --- bin/wiki/log.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/wiki/log.sh b/bin/wiki/log.sh index 4ef2c27..e96c9b4 100755 --- a/bin/wiki/log.sh +++ b/bin/wiki/log.sh @@ -8,7 +8,7 @@ grep -qE "^X-Original-To: .*log@topo.tw[>]?$" <<<"$MAIL" || exit 0 # A little hacky way to check if mail is sent from me sed -nE '/^Received: /p;/^$/q' <<<"$(MAIL)" | wc -l | xargs -i test {} -lt 2 || exit 0 -# Leave log +# Write a log date >>~/Downloads/log.log echo $$ >>~/Downloads/log.log awk -v RS= 'NR>1' <<<"$MAIL" >>~/Downloads/log.log @@ -16,6 +16,8 @@ awk -v RS= 'NR>1' <<<"$MAIL" >>~/Downloads/log.log LOG=~/log/`date +%y.w%W.md` TODAY="`date '+%a %b.%d'`" +# If header of today doesn't exist +# Create it and separate with 2 empty lines grep -Eq "^## ${TODAY}$" ${LOG} || \ cat <>${LOG} @@ -28,4 +30,5 @@ EOF echo >>${LOG} awk -v RS= 'NR>1' <<<"$MAIL" >>${LOG} +# git commit { cd ~/log && git add `basename ${LOG}` && git commit -m "Update by mail"; } >>~/Downloads/log.log -- cgit v1.2.3-70-g09d2