-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-todays-session-notes.sh
executable file
·36 lines (29 loc) · 1006 Bytes
/
create-todays-session-notes.sh
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
#!/bin/bash
# Determine the script's directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Get the current date
CURRENT_DATE=$(date +"%Y-%m-%d")
# Define the template and new file paths using the script's directory
TEMPLATE="$SCRIPT_DIR/session-notes/session-notes-template.md"
NEW_FILE="$SCRIPT_DIR/session-notes/session-notes-$CURRENT_DATE.md"
# Check if the template exists
if [ ! -f "$TEMPLATE" ]; then
echo "Error: Template not found at $TEMPLATE"
exit 1
fi
# Check if a file with today's date already exists
if [ -f "$NEW_FILE" ]; then
echo "Error: A file for today's date ($CURRENT_DATE) already exists."
exit 2
fi
# Create a new file from the template
echo "# Session Date: ${CURRENT_DATE}" > "$NEW_FILE"
# don't duplicate the session date line
cat "$TEMPLATE" | tail -n +2 >> "$NEW_FILE"
# Feedback to the user
if [ $? -eq 0 ]; then
echo "New session notes created at $NEW_FILE"
else
echo "Error while creating the session notes."
exit 3
fi