From 29b5d9481779a05cde5fe71fdddcf25c3b2e911a Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 2 May 2023 10:11:10 +0800 Subject: Update --- bin/wiki/diary | 49 ------------------------------------------------- bin/wiki/log.sh | 34 ---------------------------------- bin/wiki/notify | 7 ------- 3 files changed, 90 deletions(-) delete mode 100755 bin/wiki/diary delete mode 100755 bin/wiki/log.sh delete mode 100755 bin/wiki/notify (limited to 'bin/wiki') diff --git a/bin/wiki/diary b/bin/wiki/diary deleted file mode 100755 index d9cbe83..0000000 --- a/bin/wiki/diary +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/bash - -today=~/log/`date +%y.w%W.md` - -specify_date() { - YEAR=${YEAR:-23} - - while read -e -p 'Month? ' -r MONTH /dev/null && break - done - - while read -e -p 'Day? ' -r DAY /dev/null && break - done - - FILE=~/log/diary/`date -d $YEAR-$MONTH-$DAY +%y.w%W.md` - $EDITOR -c 'Goyo' $FILE -} - -print_today() { - [[ ! -e $today ]] && touch $today - cat $today -} - -edit_today() { - $EDITOR -c Goyo $today -} - -add_entry() { - [[ $# -ne 0 ]] && echo - "$@" >>$today - while read -e -r entry; do - echo $entry | sed -E 's/\t/ /g; s/(^[[:space:]]*)/\1- /' >>$today - done -} - -case "$1" in - specify) - specify_date ;; - print) - print_today ;; - today) - edit_today ;; - *) - add_entry "$@" ;; -esac diff --git a/bin/wiki/log.sh b/bin/wiki/log.sh deleted file mode 100755 index e96c9b4..0000000 --- a/bin/wiki/log.sh +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/bash - -# Restore mail in variable -MAIL="$(cat)" - -# Only execute the following script when mail receiver is log@topo.tw -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 - -# Write a log -date >>~/Downloads/log.log -echo $$ >>~/Downloads/log.log -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} - - -## $TODAY -EOF - - -# Save content to log file of current week -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 diff --git a/bin/wiki/notify b/bin/wiki/notify deleted file mode 100755 index 6e510d8..0000000 --- a/bin/wiki/notify +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/sh - -exec >/dev/pts/$(ls /dev/pts -t | head -1) - -echo -echo -cat -- cgit v1.2.3-70-g09d2