From c1e2b436a00117af6c63daa7f2716f4ae0038d80 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 18 Jun 2023 11:36:20 +0800 Subject: Update --- bin/log/shellrc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bin') diff --git a/bin/log/shellrc b/bin/log/shellrc index 721ed1b..a39e291 100644 --- a/bin/log/shellrc +++ b/bin/log/shellrc @@ -10,3 +10,12 @@ alias dia='diary' alias dias='diary specify' alias diaa='diary print' alias diat='diary today' + +# Filter frontmatter +wf() { + grep -m1 --include='*md' -n -o "$@" -R ~/log | \ + while IFS=: read file number pattern; do + end_of_frontmatter=$(grep -m2 -n -P '\-\-\-' $file | sed -n 2p | cut -d: -f1) + [ $number -lt "${end_of_frontmatter:-0}" ] && echo $file + done +} -- cgit v1.2.3-70-g09d2