<commit_before>#!/bin/bash

NOTESDIR="$HOME/Notes"
JOURNALDIR="$HOME/Notes/Journal" #where is this zimwiki journal?
DIR="$JOURNALDIR/$(date +%Y/%m)"
mkdir -p "$DIR"
TODAY="$DIR/$(date +%d).txt"
YESTERDAY="$JOURNALDIR/$(date -d 'yesterday' +%Y/%m/%d.txt)"
TODO="$NOTESDIR/1_-_to-Do.txt"
DAILY="$NOTESDIR/1_-_to-Do/Daily_Tasks.txt"
WEEKLY="$NOTESDIR/1_-_to-Do/Weekly_Tasks.txt"
DoW=1 #Which day of the week do I want to have weekly tasks go to? 1 = Monday, 7 = Sunday (this uses $(date +%u))
TAGS="@journal @diary"

function movetasks(){
    if [ -f "$1" ] ; then
        #Move incomplete tasks from one file to another
        sed -ne '6,/===== Future? =====\|Tasks Completed/{/===== Future? =====\|Tasks Completed/!p}' "$1" | sed -e 's/^==\(.*\)==$/=\1=/g' | grep "\[ \]\|===\|^[\s]*$" | grep -v "~~.*~~$" >> "$TODAY"
            # Truncate file before Future or Tasks Completed. Start at line 6 to avoid top header | Reduce the priority of each header. | copy undone tasks and headers | remove things that are strck through
        echo -e "\n\n" >> $TODAY
    fi
}

if [ ! -f "$TODAY" ] ; then

echo -e "Content-Type: text/x-zim-wiki
Wiki-Format: $(zim --version | head -n1)
Creation-Date: $(date +"%FT%T%:z") \n
====== $(date +"%A %d %b %Y") ====== \n
$TAGS \n
==== Tasks ==== \n\n" > "$TODAY"

echo -e "=== FROM TODO ===\n\n" >> "$TODAY"
movetasks "$TODO"

echo -e "=== FROM DAILY ===\n\n" >> "$TODAY"
movetasks "$DAILY"

if [ $(date +%u) = $DoW ] ; then
    echo -e "=== FROM WEEKLY ===\n\n" >> "$TODAY"
    movetasks "$WEEKLY"
fi

echo -e "=== FROM YESTERDAY ===\n\n" >> "$TODAY"
movetasks "$YESTERDAY"
if [ -f "$YESTERDAY" ] ; then
    if [ "$(grep -c '\[ \]' "$YESTERDAY" )" -gt 0 ] ; then
        sed -i -e '/~~/!s/\[ \] /\[x\] ~~/' -e '/~~.*~~/!s/~~.*$/&~~/' "$YESTERDAY"
        #Strike out yesterday's tasks.
        "$HOME/.dotfiles/scripts/dedupzim.py" < "$YESTERDAY" | sponge "$YESTERDAY" #little bit of cleanup
        cd "$JOURNALDIR"
        git add "$YESTERDAY"
        git commit "$YESTERDAY" -m "Moving tasks from $(date -d 'yesterday' +%F) over to $(date +%F)"
    fi
fi

echo -e "==== Tasks Completed ==== \n
==== Diary ==== \n\n" >> "$TODAY"


cat -s "$TODAY" | "$HOME/.dotfiles/scripts/dedupzim.py" | sponge "$TODAY" #This line gets rid of extraneous whitespace and duplicate lines

cd "$DIR"
git add "$TODAY"
git commit "$TODAY" -m "Initial commit: $(date +%F)"
fi
<commit_msg>breaking up lines to make version control, uh, more useful<commit_after>#!/bin/bash

NOTESDIR="$HOME/Notes"
JOURNALDIR="$HOME/Notes/Journal" #where is this zimwiki journal?
DIR="$JOURNALDIR/$(date +%Y/%m)"
mkdir -p "$DIR"
TODAY="$DIR/$(date +%d).txt"
YESTERDAY="$JOURNALDIR/$(date -d 'yesterday' +%Y/%m/%d.txt)"
TODO="$NOTESDIR/1_-_to-Do.txt"
DAILY="$NOTESDIR/1_-_to-Do/Daily_Tasks.txt"
WEEKLY="$NOTESDIR/1_-_to-Do/Weekly_Tasks.txt"
DoW=1 #Which day of the week do I want to have weekly tasks go to? 1 = Monday, 7 = Sunday (this uses $(date +%u))
TAGS="@journal @diary"

function movetasks(){
    if [ -f "$1" ] ; then
        #Move incomplete tasks from one file to another
        sed -ne '6,/===== Future? =====\|Tasks Completed/{/===== Future? =====\|Tasks Completed/!p}' "$1" \ # Truncate file before Future or Tasks Completed. Start at line 6 to avoid top header
            | sed -e 's/^==\(.*\)==$/=\1=/g' \ #Reduce the priority of each header
            | grep "\[ \]\|===\|^[\s]*$" \ #copy undone tasks and headers
            | grep -v "~~.*~~$" >> "$TODAY" #remove things that are struck through
        echo -e "\n\n" >> $TODAY
    fi
}

if [ ! -f "$TODAY" ] ; then

echo -e "Content-Type: text/x-zim-wiki
Wiki-Format: $(zim --version | head -n1)
Creation-Date: $(date +"%FT%T%:z") \n
====== $(date +"%A %d %b %Y") ====== \n
$TAGS \n
==== Tasks ==== \n\n" > "$TODAY"

echo -e "=== FROM TODO ===\n\n" >> "$TODAY"
movetasks "$TODO"

echo -e "=== FROM DAILY ===\n\n" >> "$TODAY"
movetasks "$DAILY"

if [ $(date +%u) = $DoW ] ; then
    echo -e "=== FROM WEEKLY ===\n\n" >> "$TODAY"
    movetasks "$WEEKLY"
fi

echo -e "=== FROM YESTERDAY ===\n\n" >> "$TODAY"
movetasks "$YESTERDAY"
if [ -f "$YESTERDAY" ] ; then
    if [ "$(grep -c '\[ \]' "$YESTERDAY" )" -gt 0 ] ; then
        sed -i -e '/~~/!s/\[ \] /\[x\] ~~/' -e '/~~.*~~/!s/~~.*$/&~~/' "$YESTERDAY"
        #Strike out yesterday's tasks.
        "$HOME/.dotfiles/scripts/dedupzim.py" < "$YESTERDAY" | sponge "$YESTERDAY" #little bit of cleanup
        cd "$JOURNALDIR"
        git add "$YESTERDAY"
        git commit "$YESTERDAY" -m "Moving tasks from $(date -d 'yesterday' +%F) over to $(date +%F)"
    fi
fi

echo -e "==== Tasks Completed ==== \n
==== Diary ==== \n\n" >> "$TODAY"


cat -s "$TODAY" \ #Remove extraneous whitespace
    | "$HOME/.dotfiles/scripts/dedupzim.py" \ #Remove duplicate lines
    | sponge "$TODAY"

cd "$DIR"
git add "$TODAY"
git commit "$TODAY" -m "Initial commit: $(date +%F)"
fi

{'fraction_non_alphanumeric': 0.2383685181389629, 'fraction_numerical': 0.005328960852633737, 'mean_word_length': 3.053156146179402, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1261982', 'n_tokens_mistral': 2031, 'n_tokens_neox': 1929, 'n_words': 551}