-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_talk_note.sh
More file actions
executable file
·183 lines (136 loc) · 4.27 KB
/
create_talk_note.sh
File metadata and controls
executable file
·183 lines (136 loc) · 4.27 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
#
# Time-stamp: <Sunday 2025-08-03 06:05:10 Jess Moore>
#
# Creates a markdown file for jotting notes at a talk
#
# Usage: bash create_talk_notes.sh "Jane, Bob, Liz, Sam" "ANU"
function usage() {
echo "Usage: $(basename "$0") 'speaker1, speaker2' ['affil1, affil2']"
echo ""
echo "Description: This script creates a markdown file for"
echo " talk notes prepopulated with spearker names, "
echo " optionally their affiliations, date, "
echo " summary, and discussion."
echo ""
echo "Arguments:"
echo "speakers: Comma separated attendees surrounded "
echo " in quotes."
echo "affiliations: Optionally, also provide comma separated affiliations"
echo " surrounded in quotes."
echo "meeting_group: Optional, name of meeting group, eg. 'Solid Practitioners'"
echo ""
exit 1 # Exit with a non-zero status to indicate an error
}
if [[ $# -eq 0 || $* == *"help"* || $* == *"-h"* ]]; then
usage
fi
NOW=$(date "+%A %Y-%m-%d %H:%M:%S")
AUTHOR=$(id -F)
SPEAKERS=$1
if [ -n "$2" ]; then
AFFILS=$2
else
AFFILS="To be determined"
fi
if [ -n "$3" ]; then
MTG=$3
fi
# Get date in formats for file and title
DATE_SUMM=$(date "+%Y%m%d")
DATE_STR=$(date "+%d %b %Y")
# Populate speaker and affiliation arrays, and extract speaker details for filenaming
declare -a SPEAKER_ARR
declare -a AFFIL_ARR # Use empty array if affiliations not provided
## Remove double spaces and line split
SPEAKERS_LS=$(echo "${SPEAKERS}" | sed 's/ / /g;s/, /\n/g')
N_SPEAKERS=$(echo "$SPEAKERS_LS" | wc -l)
if [ -n "${AFFILS}" ]; then
AFFILS_LS=$(echo "${AFFILS}" | sed 's/ / /g;s/, /\n/g')
N_AFFILS=$(echo "$AFFILS_LS" | wc -l)
fi
echo "Speakers: "
echo "${SPEAKERS_LS}"
echo "N speakers: $N_SPEAKERS"
if [ -n "${AFFILS}" ]; then
echo "Affiliations: "
echo "${AFFILS_LS}"
echo "N affiliations: $N_AFFILS"
else
N_AFFILS=0
fi
echo "Extracting speakers and affiliations..."
for i in $(seq 0 $((N_SPEAKERS - 1))); do
line_num=$((i+1))
SPEAKER_ARR[i]="$(echo "$SPEAKERS_LS" | awk "NR==$line_num")"
echo "$i: ${SPEAKER_ARR[i]}"
if [[ $N_AFFILS -gt $i ]]; then
AFFIL_ARR[i]="$(echo "$AFFILS_LS" | awk "NR==$line_num")"
else
AFFIL_ARR[i]="(Unknown affiliation)"
fi
echo "$i: ${AFFIL_ARR[i]}"
if [[ "$i" == "0" ]]; then
SPEAKER1=$(echo "${SPEAKER_ARR[i]}" | awk '{print tolower($0);}' | sed 's/ //g')
echo "Speaker 1: ${SPEAKER1}"
elif [[ "$i" == "1" ]]; then
# Form speaker string part of filename for 2 speakers
SPEAKER2=$(echo "${SPEAKER_ARR[i]}" | awk '{print tolower($0);}' | sed 's/ //g')
echo "Speaker 2: ${SPEAKER2}"
fi
done
# Form speaker string part of filename
if [[ ${N_SPEAKERS} -eq 1 ]]; then
# 1 speaker
SPEAKER_STR="${SPEAKER1}"
echo "Defining filename speaker_str for 1 speaker"
elif [[ ${N_SPEAKERS} -eq 2 ]]; then
# 2 speakers
SPEAKER_STR="${SPEAKER1}_${SPEAKER2}"
echo "Defining filename speaker_str for 2 speakers"
elif [[ ${N_SPEAKERS} -gt 2 ]]; then
# More than 2 speakers
SPEAKER_STR="${SPEAKER1}_etal"
echo "Defining filename speaker_str for > 2 speakers"
fi
echo "Speaker string:${SPEAKER_STR}"
# Set talk note title and filename
if [[ -n $MTG ]]; then
# Title: use mtg name if provided
TITLE="${MTG} - ${DATE_STR}"
# Filename: use mtg name if provided
FILENAME="${DATE_SUMM}-${MTG}.md"
else
# Title using speakers
TITLE="${SPEAKERS} on XYZ"
# Make file name with syntax YYMMDD-speakers.md
FILENAME="${DATE_SUMM}-${SPEAKER_STR}.md"
fi
# Write header
cat > "${FILENAME}" << EOF
# ${TITLE}
*Speakers: ${SPEAKERS}
*Affiliations: ${AFFILS}*
*Date: ${NOW} ${AUTHOR}*
## Summary
- Foo
- Foo2
## Discussion
EOF
# Write speaker subheading sections
for i in $(seq 0 $((N_SPEAKERS - 1))); do
cat >> "${FILENAME}" << EOFF
### ${SPEAKER_ARR[i]}
*${AFFIL_ARR[i]}*
EOFF
done
# Write footer
cat >> "${FILENAME}" << EOFFF
<!-- markdownlint-disable-file MD009 MD012 MD013 MD036 -->
<!-- MD009 - no trailing spaces -->
<!-- MD012 - no multiple blanks -->
<!-- MD013 - line limit -->
<!-- MD036 - emphasised text as heading -->
EOFFF
ls -l "${FILENAME}"
echo "Done."