1
0
mirror of https://github.com/RyanGreenup/cadmus.git synced 2025-04-21 02:01:50 +02:00

[TOOLS] Added Backlinks

This commit is contained in:
Ryan Greenup 2020-07-16 08:50:59 +10:00
parent 4c078f69aa
commit 55e51a402c
2 changed files with 28 additions and 7 deletions

View File

@ -196,8 +196,9 @@ CadmusTools () {
case "$1" in
webtitle) shift; "${script_dir}/tools/PrintWebTitle.sh"
;;
backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "${NOTES_DIR}" ${@:-} && exit 0
;;
create) shift; "${script_dir}/tags/tags-to-TMSU.sh" "${NOTES_DIR}" ${@:-} && exit 0
./
;;
--*) >&2 echo "bad option $1"
;;
@ -216,12 +217,13 @@ function ToolsHelp() {
echo -e " \e[3m\e[1m Cadmus Tools\e[0m; Tools for Editing Notes "
echo -e " \e[1;31m -------------------------\e[0m "
echo
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
echo -e " ...........................\e[1;34m┊┊┊\e[0m........................................... "
echo -e " \e[1;93m WORKING webtitle \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Transforms the Clipboard 📋 to a Link"
echo -e " \e[1;93m TODO Print Backlinks \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
echo -e " \e[1;93m TODO Repair Link \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
echo -e " \e[1;32m TODO Import WebPage \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Search through Notes using Recoll"
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
echo -e " .......................\e[1;34m┊┊┊\e[0m........................................... "
echo -e " \e[1;93m webtitle \e[0m \e[1;34m ┊┊┊ \e[0m✀ Transforms the Clipboard 📋 to a Link"
echo -e " \e[1;93m backlinks \e[0m \e[1;34m ┊┊┊ \e[0m✀ Takes the Abs Path of a Note from the Clipboard 📋"
echo -e " \e[1;93m \e[0m \e[1;34m ┊┊┊ \e[0m and prints out backlinks (Abs Path)"
echo -e " \e[1;93m TODO Repair Link \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
echo -e " \e[1;32m TODO Import WebPage \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Search through Notes using Recoll"
echo
echo -e " \e[3m\e[1m• Legend\e[0m "
echo -e " ✀ Works with the clipboard for input/output."

19
bin/tools/List-Backlinks.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
command -v rg >/dev/null 2>&1 || { echo >&2 "I require ripgrep but it's not installed. Aborting."; exit 1; }
command -v sd >/dev/null 2>&1 || { echo >&2 "I require sd (sed replacement) but it's not installed. Aborting."; exit 1; }
command -v xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not installed. Aborting."; exit 1; }
term=$(xclip -selection clipboard -o | xargs basename | cut -f 1 -d '.')
rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
~/Notes/MD/notes \
-t markdown -ol
## If you want to preview the Backlinks
## rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
## ~/Notes/ -t markdown -ol \
## fzf --bind pgup:preview-page-up,pgdn:preview-page-down --preview "mdcat {}"