diff --git a/bash_aliases_clip b/bash_aliases_clip index 386a6f5..b639b20 100644 --- a/bash_aliases_clip +++ b/bash_aliases_clip @@ -2,6 +2,14 @@ # zn aliases alias zn="zn -p $HOME/.notes/notes" alias znt="zn -p $HOME/.notes/notes -t" +alias zntl="ztl.sh $HOME/.notes/notes" +alias znts="zts.sh $HOME/.notes/notes" alias zj="zn -p $HOME/.notes/journal" alias zjt="zn -p $HOME/.notes/journal -t" +alias zjtl="ztl.sh $HOME/.notes/journal" +alias zjts="zts.sh $HOME/.notes/journal" +alias zw="zn -p $HOME/.notes/wfh-notes" +alias zwt="zn -p $HOME/.notes/wfh-notes -t" +alias zwtl="ztl.sh $HOME/.notes/wfh-notes" +alias zwts="zts.sh $HOME/.notes/wfh-notes" diff --git a/ztl.sh b/ztl.sh new file mode 100755 index 0000000..de6f721 --- /dev/null +++ b/ztl.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +############################################################################## +# +# Simple script to generate tag list for zn +# +############################################################################## + +# Path to note dir expected as $1 +# Tag to search for expected as $2 - can be omitted to search all + +if [ -z "$2" ]; then + rg --no-line-number --no-heading '^\#[a-zA-Z0-9]' ${1}/*.md | cut -d':' -f2 | sort | uniq -c +else + rg --no-line-number --no-heading --ignore-case "^#${2}" ${1}/*.md | cut -d':' -f2 | sort | uniq -c +fi + diff --git a/zts.sh b/zts.sh new file mode 100755 index 0000000..ff40572 --- /dev/null +++ b/zts.sh @@ -0,0 +1,29 @@ +#!/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 +