From: Edward Delaporte Date: Tue, 23 Jun 2026 22:23:21 +0000 (-0500) Subject: Add minion gather command X-Git-Url: https://apps.delaporte.us/gitweb/minion.git/commitdiff_plain/1d86c266176f7d02d112be5583b9ebd7a69e570f?hp=a547243528179f0659cc1cd7d97e9d50e4a76b0c Add minion gather command --- diff --git a/bin/mg b/bin/mg new file mode 100755 index 0000000..e803fe6 --- /dev/null +++ b/bin/mg @@ -0,0 +1,59 @@ +#!/bin/bash +# mg - minion gather +# Creates a new file $HOME/Journal/YYYY/MM-topic.md with all contents from all matches for all terms +# Optionally include a second search term + +year=`date +%Y` +# File to gather all content into +topic=$1 +if [ ! -n "$1" ]; then + echo "A topic to gather is required." + exit 1 +fi +fname=$(printf "$HOME/Journal/$year/%02d-$topic.md" $(date +%m)) +archive="$HOME/Journal/archive-$year/" + +# Files to gather +files=$(find $HOME/Journal/$year -type f -iname "*$1*\.md") +if [ -n "$files" ]; then + echo "Will merge $files into $fname" +else + echo "Nothing to gather for $topic" +fi + +# optional - more files to gather +if [ -n "$2" ]; then + more_files=$(find $HOME/Journal/$year -type f -iname "*$2*\.md") +fi +if [ -n "$more_files" ]; then + echo "Will merge $more_files into $fname" +else + echo "Nothing to gather for $2" +fi + +echo "" +read -n1 -p "Continue? [y,N]" input +echo "" +if [[ ! $input == "Y" && ! $input == "y" ]]; then + echo "Aborted by user" + exit 1 +fi + +echo "Huzzah!" +cat $files >> $fname.gathered +mkdir -p $archive +mv $files $archive + +if [ -n "$more_files" ]; then + cat $more_files >> $fname.gathered + mv $more_files $archive +fi + +mv $fname.gathered $fname + +if [ -z ${EDITOR} ]; then + echo "EDITOR unset, defaulting to Nano" + export EDITOR=nano +fi +$EDITOR $fname + diff --git a/bin/mh b/bin/mh index ffbbce3..202606d 100755 --- a/bin/mh +++ b/bin/mh @@ -16,6 +16,7 @@ echo "mo manager - open files named with 'manager' to edit" echo "" echo "Advanced Usage:" echo "" +echo "mg - minion gather - gather matching files into a single file" echo "mp - minion print - convert matching files to HTML and open in Firefox (requires https://github.com/gomarkdown/markdown)" echo "ms - minion spell - open the matching file with 'aspell'" echo "mla, moa, etc - minion X all - act as 'ml' and 'mo', but include all previous years of Journal entries"