-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraft_email.sh
More file actions
executable file
·69 lines (45 loc) · 1.31 KB
/
draft_email.sh
File metadata and controls
executable file
·69 lines (45 loc) · 1.31 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# Time-stamp: <Monday 2025-08-18 13:05:58 Jess Moore>
#
# Create a draft of an email in markdown
#
# Usage: draft_email.sh [args...]
function usage() {
echo "Usage: draft_email recipient"
echo ""
echo "Description: Create a draft of an email in markdown."
echo ""
echo "Arguments:"
echo " recipient: Name of recipient"
echo ""
exit 1 # Exit with a non-zero status to indicate an error
}
if [[ $# -eq 0 || $* == *"help"* || $* == *"-h"* ]]; then
usage
fi
RECIPIENT=$1
SENDER=$(id -F)
NOW=$(date "+%A %Y-%m-%d %H:%M:%S")
## Form filename with syntax YYmmdd-draftEmailTo-person.md
# Convert recipient to lower Camel Case
PEOPLE_SUMM=$(echo "$RECIPIENT" | awk '{print tolower($0);}' | awk '{print $1, toupper(substr($2,1,1)) substr($2,2)}' | sed 's/ //g')
SENDER_FIRSTNAME=$(echo "$SENDER" | awk '{print $1}')
DATE_SUMM=$(date "+%Y%m%d")
# Form filename
FILENAME="${DATE_SUMM}-draftEmailTo-${PEOPLE_SUMM}.md"
cat > "${FILENAME}" << EOF
*From: ${SENDER}*
*To: ${RECIPIENT}*
**Subject: [ADD]**
*Date: ${NOW} ${SENDER}*
Hi [ADD]
Regards,
${SENDER_FIRSTNAME}
[ADD SIGNATURE]
<!-- markdownlint-disable-file MD009 MD012 MD013 MD029 MD036 MD041 -->
<!-- Ignores line length limit, no trailing spaces, multiple blanks, etc -->
EOF
echo "Done"
echo "Output: "
ls -l "$FILENAME"