Automated_Journal_VimWiki/scripts/update_full_index.sh

38 lines
827 B
Bash
Raw Normal View History

#!/opt/homebrew/bin/bash
2023-06-14 19:15:13 +00:00
#set -x
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh
JOURNAL_FULL_INDEX=$PROJ_DIR/full_index.wiki
2023-06-14 19:15:13 +00:00
declare -a journals
get_journals journals
echo "
%title Full Index
# Journals: Times & Topics
$(
for file_path in ${journals[@]}; do
file="${file_path/*\/}"
journal_full_path=$PROJ_DIR$file_path
2023-06-14 19:15:13 +00:00
echo -e '\n\n'
echo "[[$file_path|$(echo $file | cut -d '.' -f 1 | tr '-' '/')]]"
2023-06-14 19:15:13 +00:00
echo "# Times"
while read time; do
echo " - [[$file_path#$time|$time]]"
done <<< "$( grep '== ' $journal_full_path | grep -Eo '[0-9]+:[0-9]+ [A-Za-z]{2} [A-Za-z]{3}')"
2023-06-14 19:15:13 +00:00
echo
echo "# Topics"
while read topic; do
echo " - [[$file_path#$topic|$topic]]"
done <<< "$( grep -Eo '^===[=]* .+ ===[=]*' $journal_full_path | tr '=' ' ' | sort -u)"
2023-06-14 19:15:13 +00:00
done
)
" > $JOURNAL_FULL_INDEX