Skip to content

Instantly share code, notes, and snippets.

@perchard
Created September 1, 2019 21:29
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save perchard/04458b46f63e5288de79b038fcbcecae to your computer and use it in GitHub Desktop.
cd ~/Dropbox/zettelkasten
query=$1
result=$(egrep -ohs '^Tags:.*$' -- * | egrep -ohs '#[A-Za-z0-9_\-]+' | egrep -hs "$query" | sort | uniq | sed -e 's/.*/{"title":"&","arg":"&"},/' -e '1s/^/{"items":[/' -e '$s/$/]}/')
if [ -n "$result" ]
then
echo $result
else
echo "{\"items\":[{\"title\":\"Create Tag: #$query\",\"arg\":\"#$query\"}]}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment