From 0a491b554c371f6654bc68761c536a8c0f97c01d Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sat, 4 Dec 2021 17:44:36 +0100 Subject: [PATCH] Add wiki script --- .wiki/scripts/anki/index-decks | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 .wiki/scripts/anki/index-decks diff --git a/.wiki/scripts/anki/index-decks b/.wiki/scripts/anki/index-decks new file mode 100755 index 0000000..496a171 --- /dev/null +++ b/.wiki/scripts/anki/index-decks @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# +# Script to create a markdown file containing links to all filenames prefixed +# with "anki-" +# + +wiki="$HOME/.wiki" + +find "$wiki"/anki-*.md -printf "%f\n" > "$HOME/.wiki/scripts/anki/links" +find "$wiki"/anki-*.md -exec head -n 1 {} \; > "$HOME/.wiki/scripts/anki/titles" + +sed -i -e 's/^/(/' links -e 's/$/)/' # Wrap links in parentheses +sed -i -e 's/^/[/' titles -e 's/$/]/' # Wrap titles in square brackets +sed -i -e 's/^\[#\ /* \[/' titles # Remove '#' and add list bullet + +echo "# My anki decks\n" > "$HOME/.wiki/my-anki.md" # Clear file and add markdown title +paste titles links -d "" >> "$HOME/.wiki/my-anki.md" # Concatenate & append to file