mirror of
https://github.com/kmein/niveum
synced 2026-03-20 03:51:07 +01:00
feat(packages): notetags script
This commit is contained in:
@@ -92,6 +92,11 @@ in
|
|||||||
name = "nix-git";
|
name = "nix-git";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
notetags = makeScript {
|
||||||
|
src = ./notetags.sh;
|
||||||
|
name = "notetags";
|
||||||
|
};
|
||||||
|
|
||||||
bvg = pkgs.callPackage ./bvg.nix {};
|
bvg = pkgs.callPackage ./bvg.nix {};
|
||||||
nav = pkgs.callPackage ./nav.nix {};
|
nav = pkgs.callPackage ./nav.nix {};
|
||||||
}
|
}
|
||||||
|
|||||||
15
packages/scripts/notetags.sh
Executable file
15
packages/scripts/notetags.sh
Executable 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
|
||||||
Reference in New Issue
Block a user