feat(script/note): note bookmark and note link

This commit is contained in:
Malte Tammena 2024-04-29 11:28:19 +02:00
parent 29b136c983
commit 01edb9c33c

View file

@ -51,6 +51,10 @@ function print_help_and_exit() {
printf " Execute a git command in the note repository\n"
printf " dir\n"
printf " Print the note directory\n"
printf " bm | bookmark | bookmarks\n"
printf " List all bookmarks\n"
printf " link | links\n"
printf " List all links\n"
printf " log\n"
printf " Print the entire note file\n"
exit 1
@ -69,6 +73,8 @@ function run_git_command_by_args_and_exit() {
ONLY_TODOS=
ONLY_DONE=
ONLY_DAY=
ONLY_LINKS=
ONLY_BOOKMARKS=
FILTER_TAG=
while [[ $# -gt 0 ]]; do
@ -103,6 +109,14 @@ while [[ $# -gt 0 ]]; do
echo "$XDG_DATA_HOME/life.md"
exit
;;
bm | bookmark | bookmarks)
shift
ONLY_BOOKMARKS=1
;;
link | links)
shift
ONLY_LINKS=1
;;
log)
shift
;;
@ -139,6 +153,10 @@ bat "$XDG_DATA_HOME/life.md/$year.md" |
}
elif [ -n "$ONLY_DAY" ]; then
rg --multiline --multiline-dotall "# $(date -d "$ONLY_DAY" +%Y-%m-%d)(.*?\n#[^#]|.*)"
elif [ -n "$ONLY_LINKS" ]; then
rg '\[[^]]+\]\([^)]+\)' --only-matching | sed 's/^/- /' | sort
elif [ -n "$ONLY_BOOKMARKS" ]; then
rg '[+-] bookmark: \[[^]]+\]\([^)]+\)' --only-matching | sed 's/+ bookmark: /+ /' | sort
else
cat
fi