summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-09-06 10:29:29 +0200
committerFlorian Pritz <bluewind@xinu.at>2014-09-06 10:29:29 +0200
commitf653f4437e046b49d77a4b70980029c05f133157 (patch)
tree2dda230f405c58a2de35bd5c9a7c78cc78615aec
parent94761c1f439ccc5ac9a6ac609873211d6f83f211 (diff)
downloadbin-f653f4437e046b49d77a4b70980029c05f133157.tar.gz
bin-f653f4437e046b49d77a4b70980029c05f133157.tar.xz
Add todo
Original source: https://bitbucket.org/jasonwryan/centurion/src/tip/Scripts/todo Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--todo56
1 files changed, 56 insertions, 0 deletions
diff --git a/todo b/todo
new file mode 100644
index 0000000..2169665
--- /dev/null
+++ b/todo
@@ -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: