1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00

feat(packages): notetags script

This commit is contained in:
Kierán Meinhardt
2020-04-09 19:30:35 +02:00
parent cf339a930b
commit a0ddfff751
2 changed files with 20 additions and 0 deletions

View File

@@ -92,6 +92,11 @@ in
name = "nix-git";
};
notetags = makeScript {
src = ./notetags.sh;
name = "notetags";
};
bvg = pkgs.callPackage ./bvg.nix {};
nav = pkgs.callPackage ./nav.nix {};
}

15
packages/scripts/notetags.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# inspired by https://github.com/connermcd/bin/blob/1d38cb98812906d8b95dc6e51e1149e29261617d/notetags
cd "$HOME/notes/" || exit
[[ -f tags ]] && rm tags
grep -r 'tags:' ./* | while read -r line; do
file=$(echo "$line" | cut -d: -f1)
unparsed_tags=$(echo "$line" | cut -d: -f3) #
tags=$(echo "$unparsed_tags" | sed -e 's/tags: *//g' -e 's/[][,]//g')
for tag in $tags; do
echo "$tag $file /^$unparsed_tags$/;" >> tags
done
done