diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-09-06 10:30:29 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-09-06 10:30:29 +0200 |
commit | e59d9c40e64cb5e6fb4fcfd6401583c03bbd99be (patch) | |
tree | dbebd8132855a3e8859a27d9f396df9b2bc8c311 | |
parent | f653f4437e046b49d77a4b70980029c05f133157 (diff) | |
download | bin-e59d9c40e64cb5e6fb4fcfd6401583c03bbd99be.tar.gz bin-e59d9c40e64cb5e6fb4fcfd6401583c03bbd99be.tar.xz |
todo: multiple changes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x[-rw-r--r--] | todo | 43 |
1 files changed, 24 insertions, 19 deletions
@@ -1,6 +1,9 @@ #!/usr/bin/env bash # email reminder notes using at(1)... +TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")" +trap "rm -rf '${TMPDIR}'" EXIT TERM + usage() { cat <<EOF Options: @@ -17,40 +20,42 @@ alist() { } aprint() { - awk -F\" '/gmail/ { print $2 }' <(at -c "$@") + awk -F\" '/@/ { 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 + while :; do + date="$(rlwrap -H "$TMPDIR/date-history" -S "Date and time of message? " -o head -n1)" + parsed_date="$(date -d "$date")" || continue + printf "Job will be run at around %s\n" "$parsed_date" - timexp='^[0-9]{2}:[0-9]{2}' - datexp='^[0-9]{2}.[0-9]{2}.[0-9]{2}' + attime="$(date -d "$date" +%H:%M)" + atdate="$(date -d "$date" +%D)" + break; + done + + read -p "Message body? " message - if [[ $attime =~ $timexp && $atdate =~ $datexp ]]; then - at "$attime" "$atdate" << EOF - printf '%s\n' "$message" | mutt -s "REMINDER" jasonwryan@gmail.com + at "$attime" "$atdate" << EOF + printf '%s\n' "$message" | mail -s "REMINDER" bluewind@xinu.at 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 - ;; + ;; + *) usage && exit 1 + ;; esac -else usage && exit 1 +else + aread fi # vim:set ts=2 sts=2 sw=2 et: |