summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]todo43
1 files changed, 24 insertions, 19 deletions
diff --git a/todo b/todo
index 2169665..318610d 100644..100755
--- a/todo
+++ b/todo
@@ -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: