]>
us-delaporte.pagekite.me Git - minion.git/blob - bin/mg
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
8 # File to gather all content into
10 if [ ! -n "$1" ]; then
11 echo "A topic to gather is required."
15 mkdir -p "$HOME/Journal/$year"
16 fname
="$HOME/Journal/$year/$month-$topic.md"
17 archive
="$HOME/Journal/archive-$year/"
20 files
=$(find $HOME/Journal/$year -type f -iname "*$1*\.md")
21 if [ -n "$files" ]; then
22 echo "Will merge $files into $fname"
24 echo "Nothing to gather for $topic"
27 # optional - more files to gather
29 more_files
=$(find $HOME/Journal/$year -type f -iname "*$2*\.md")
31 if [ -n "$more_files" ]; then
32 echo "Will merge $more_files into $fname"
34 echo "No second keyword."
38 read -n1 -p "Continue? [y,N]" input
40 if [[ ! $input == "Y" && ! $input == "y" ]]; then
41 echo "Aborted by user"
46 echo "Gathering $f into $fname"
47 cat "$f" >> "$fname.gathered"
53 if [ -n "$more_files" ]; then
55 for f
in $more_files; do
56 echo "Gathering $f into $fname"
57 cat "$f" >> "$fname.gathered"
60 mv $more_files $archive
63 mv $fname.gathered
$fname
65 if [ -z ${EDITOR} ]; then
66 echo "EDITOR unset, defaulting to Nano"