]>
apps.delaporte.us Git - minion.git/blob - bin/mg
e803fe65a39790e9b17d3b44d6c2eb594ce9eca0
3 # Creates a new file $HOME/Journal/YYYY/MM-topic.md with all contents from all matches for all terms
4 # Optionally include a second search term
7 # File to gather all content into
10 echo "A topic to gather is required."
13 fname
=$(printf "$HOME/Journal/$year/%02d-$topic.md" $(date +%m))
14 archive
="$HOME/Journal/archive-$year/"
17 files
=$(find $HOME/Journal/$year -type f -iname "*$1*\.md")
18 if [ -n "$files" ]; then
19 echo "Will merge $files into $fname"
21 echo "Nothing to gather for $topic"
24 # optional - more files to gather
26 more_files
=$(find $HOME/Journal/$year -type f -iname "*$2*\.md")
28 if [ -n "$more_files" ]; then
29 echo "Will merge $more_files into $fname"
31 echo "Nothing to gather for $2"
35 read -n1 -p "Continue? [y,N]" input
37 if [[ ! $input == "Y" && ! $input == "y" ]]; then
38 echo "Aborted by user"
43 cat $files >> $fname.gathered
47 if [ -n "$more_files" ]; then
48 cat $more_files >> $fname.gathered
49 mv $more_files $archive
52 mv $fname.gathered
$fname
54 if [ -z ${EDITOR} ]; then
55 echo "EDITOR unset, defaulting to Nano"