Automated_Journal_VimWiki/scripts/utils/tasks.sh

27 lines
654 B
Bash
Raw Permalink Normal View History

#!/opt/homebrew/bin/bash
[[ -f ~/Notes/utils/journals.sh ]] && . ~/Notes/utils/journals.sh
2023-06-14 19:15:13 +00:00
function get_tasks () {
set -x
local -a journals
get_journals journals
local TASK_REGEX='====[[:space:]]+.+[[:space:]]+===='
declare -n TODO="$1"
declare -n DONE="$2"
for journal in "${journals[@]}"; do
if grep -Eo $TASK_REGEX $journal >/dev/null 2>&1; then
while read line; do
if [[ "$line" == *'(DUE: DONE)'* ]]; then
DONE["$journal"]="$( echo -e "${DONE["$journal"]}\n$line" )"
else
TODO["$journal"]="$( echo -e "${TODO["$journal"]}\n$line" )"
fi
done <<< "$( grep -Eo $TASK_REGEX $journal | tr '=' ' ')"
fi
done
}