added scripts to list (ztl.sh) or search (zts.sh) tags

updated bash_aliases for new scripts
This commit is contained in:
Radar231 2022-05-08 10:44:54 -04:00
parent c5b1e4a592
commit 8a3dd477e1
3 changed files with 53 additions and 0 deletions

View File

@ -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"

16
ztl.sh Executable file
View File

@ -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

29
zts.sh Executable file
View File

@ -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