#!/usr/bin/env bash ############################################################################## # # Simple script to search zn notes for a specific tag # ############################################################################## # Path to note dir expected as $1 # Tag to search for expected as $2 list=$(rg --ignore-case --no-heading --no-line-number --files-with-matches "^#${2}" ${1}/*.md) echo "" echo " Tags:"; echo " -----" rg --ignore-case --no-heading --no-line-number "^#${2}" ${1}/*.md | cut -d':' -f2 | sort | uniq -c echo "" srch-res() { for i in $list do datetime=$(basename $i | sed 's/.md$//') title=$(head -1 $i | cut -d' ' -f2-) echo "(${datetime}): ${title}" done } srch-res "" | sort -n