blob: 216966576ec8abc3c8c97398cb7b1314368a0961 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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:
|