]>
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
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 "No second keyword."
35 read -n1 -p "Continue? [y,N]" input
37 if [[ ! $input == "Y" && ! $input == "y" ]]; then
38 echo "Aborted by user"
43 echo "Gathering $f into $fname"
44 cat "$f" >> "$fname.gathered"
50 if [ -n "$more_files" ]; then
52 for f
in $more_files; do
53 echo "Gathering $f into $fname"
54 cat "$f" >> "$fname.gathered"
57 mv $more_files $archive
60 mv $fname.gathered
$fname
62 if [ -z ${EDITOR} ]; then
63 echo "EDITOR unset, defaulting to Nano"