-
Notifications
You must be signed in to change notification settings - Fork 0
/
mutt
executable file
·46 lines (33 loc) · 1.13 KB
/
mutt
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
#!/bin/sh
set -e
set -u
path="/usr/bin/mutt"
command="${path##*/}"
folder="$HOME"/50_59_self_improvement/52_habits/"$command"_count
file="$folder"/"$(date --iso-8601)"
mkdir -p "$folder"
r="$(date +%N | cut -c 1-6)"
echo "Write $r"
read -r rr
if [ "$rr" != "$r" ]; then
echo "Wrong code, exiting..."
exit 1
fi
first_reason="need to send email"
second_reason="read email"
third_reason="override for a perfectly good reason"
echo "Write '$first_reason' or '$second_reason' or '$third_reason'"
read -r reason
if [ "$reason" = "$first_reason" ] || [ "$reason" = "$second_reason" ] || [ "$reason" = "$third_reason" ]; then
if [ "$reason" = "$second_reason" ] && [ -f "$file" ]; then
echo "Emails already read today!"
exit 2
fi
printf "%s\n" "$(date --iso-8601=minutes)" >> "$file"
arg="-F ${XDG_CONFIG_DIR:=$HOME/.config}/mutt/muttrc"
"$path" $arg "$@"
fi
# we could directly iterate over the line with awk and do "sleep 1" for every
# line, but we prefer to close the file ASAP instead.
# waiting for as many lines in seconds
# wc -l "$file" | awk '{print "Waiting " $1 " seconds..." ; system("sleep " $1)}' && "$path" $arg "$@"