54 lines
1.3 KiB
Bash
Executable file
54 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Set variables
|
|
today=$(date +%Y-%m-%d)
|
|
daily_note_dir="$NOTES_DIR/daily_notes"
|
|
today_file="${daily_note_dir}/${today}_daily.md"
|
|
most_recent_file=$(ls -t ${daily_note_dir}/*_daily.md | head -n 1)
|
|
month=$(date +%m)
|
|
day=$(date +%d)
|
|
|
|
# Function to find unticked checkboxes in the most recent daily note
|
|
find_unticked_checkboxes() {
|
|
if [[ -f "$most_recent_file" ]]; then
|
|
grep -E '^\s*[-*]\s+\[ \]' "$most_recent_file"
|
|
else
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
# Function to add aoc checkbox if it's December before the 24th
|
|
add_aoc_checkbox() {
|
|
if [[ "$month" == "12" && "$day" -lt "25" ]]; then
|
|
echo "- [ ] Advent of Code"
|
|
fi
|
|
}
|
|
|
|
# Check if today's daily note exists
|
|
if [[ -f "$today_file" ]]; then
|
|
echo "Today's daily note already exists. Opening with neovim..."
|
|
nvim "$today_file"
|
|
else
|
|
echo "Creating today's daily note from template..."
|
|
{
|
|
echo "---"
|
|
echo "tags:"
|
|
echo "created_at: ${today}"
|
|
echo "---"
|
|
echo "# To-Do"
|
|
find_unticked_checkboxes
|
|
add_aoc_checkbox
|
|
# echo "- [ ]"
|
|
echo ""
|
|
echo "# Logbook"
|
|
echo ""
|
|
echo "# Linked notes"
|
|
echo ""
|
|
echo "# Resources"
|
|
echo ""
|
|
} > "$today_file"
|
|
|
|
echo "Opening today's daily note with neovim..."
|
|
nvim "$today_file"
|
|
fi
|
|
|