diff options
-rw-r--r-- | todo | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# email reminder notes using at(1)... + +usage() { + cat <<EOF + Options: + -c | create job + -l | list current jobs + -p n | print details for job n + -h | print this message + +EOF +} + +alist() { + atq | sort -r -k3M -k4 +} + +aprint() { + awk -F\" '/gmail/ { print $2 }' <(at -c "$@") +} + +aread() { + read -p "Time of message? [HH:MM] " attime + read -p "Date of message? [DD.MM.YY] " atdate + read -p "Message body? " message + + timexp='^[0-9]{2}:[0-9]{2}' + datexp='^[0-9]{2}.[0-9]{2}.[0-9]{2}' + + if [[ $attime =~ $timexp && $atdate =~ $datexp ]]; then + at "$attime" "$atdate" << EOF + printf '%s\n' "$message" | mutt -s "REMINDER" jasonwryan@gmail.com +EOF + else + printf '%s\n' "Incorrectly formatted values, bailing..." && exit 1 + fi +} + +if (( $# >= 1 )); then + case "$1" in + -c) aread + ;; + -p) aprint "$2" + ;; + -l) alist + ;; + -h) usage + ;; + *) usage && exit 1 + ;; + esac +else usage && exit 1 +fi + +# vim:set ts=2 sts=2 sw=2 et: |