diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/init/load-settings.sh | 2 | ||||
-rwxr-xr-x | bin/mail/log.sh (renamed from bin/log/log.sh) | 0 | ||||
-rwxr-xr-x | bin/mail/save_context.sh | 19 |
3 files changed, 21 insertions, 0 deletions
diff --git a/bin/init/load-settings.sh b/bin/init/load-settings.sh index 960f407..d3e092b 100755 --- a/bin/init/load-settings.sh +++ b/bin/init/load-settings.sh | |||
@@ -17,6 +17,8 @@ export shell=${shell##*/} | |||
17 | 17 | ||
18 | # load custom aliases | 18 | # load custom aliases |
19 | source $SETTING_DIR/alias | 19 | source $SETTING_DIR/alias |
20 | |||
21 | # sourcr rc files | ||
20 | [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done | 22 | [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done |
21 | find $SETTING_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done | 23 | find $SETTING_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done |
22 | 24 | ||
diff --git a/bin/log/log.sh b/bin/mail/log.sh index e96c9b4..e96c9b4 100755 --- a/bin/log/log.sh +++ b/bin/mail/log.sh | |||
diff --git a/bin/mail/save_context.sh b/bin/mail/save_context.sh new file mode 100755 index 0000000..5cc9400 --- /dev/null +++ b/bin/mail/save_context.sh | |||
@@ -0,0 +1,19 @@ | |||
1 | #! /bin/bash | ||
2 | |||
3 | # Restore mail in variable | ||
4 | MAIL="$(cat)" | ||
5 | |||
6 | # Only execute the following script when mail receiver is log@topo.tw | ||
7 | grep -qE "^X-Original-To: .*context@topo.tw[>]?$" <<<"$MAIL" || exit 0 | ||
8 | # A little hacky way to check if mail is sent from me | ||
9 | sed -nE '/^Received: /p;/^$/q' <<<"$(MAIL)" | wc -l | xargs -i test {} -lt 2 || exit 0 | ||
10 | |||
11 | # Write a log | ||
12 | cat <<<"$MAIL" >>~/Downloads/context.log | ||
13 | |||
14 | # Save content to log file of current week | ||
15 | /home/pham/helper/bin/task/context $(awk -v RS= 'NR>1' <<<"$MAIL") | ||
16 | |||
17 | /home/pham/helper/bin/task/context | cut -f1-3 | /usr/bin/mail -r context@topo.tw -C "chat-version: 1.0" -s no-reply pham | ||
18 | |||
19 | cd ~/log && git add context/* && git commit -m 'Append time by mail' | ||