From bdb1fc9e15d6c1aaf548109407740925f9f71220 Mon Sep 17 00:00:00 2001 From: ryangreenup Date: Fri, 24 Jul 2020 00:54:28 +1000 Subject: [PATCH] [Fix] makeLink now takes arguments not xclip, #1 --- bin/cadmus | 2 +- bin/tools/LinkMarkdownNotes.sh | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bin/cadmus b/bin/cadmus index 3bd54f3..b56fc1c 100755 --- a/bin/cadmus +++ b/bin/cadmus @@ -299,7 +299,7 @@ CadmusTools () { ;; backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "${NOTES_DIR}" ${@:-} && exit 0 ;; - link) shift; "${script_dir}/tools/LinkMarkdownNotes.sh" "${NOTES_DIR}" | CLIP_IN && exit 0 + link) shift; "${script_dir}/tools/LinkMarkdownNotes.sh" "${NOTES_DIR}" "$(CLIP_OUT)" | CLIP_IN && exit 0 ;; fix) shift; "${script_dir}/tools/fixLink.sh" "${NOTES_DIR}" && exit 0 ;; diff --git a/bin/tools/LinkMarkdownNotes.sh b/bin/tools/LinkMarkdownNotes.sh index a673ee9..ee9d254 100755 --- a/bin/tools/LinkMarkdownNotes.sh +++ b/bin/tools/LinkMarkdownNotes.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash - + readonly script_name=$(basename "${0}") if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then - echo " - The input file is taken from the clipboard, - choose the output file and a relative MD link - will be generated" + + echo " ${script_name} /path/to/dir input-file" + echo "I should probably handle arguments more elegantly" exit 0 elif [[ $1 != '' ]]; then @@ -18,10 +17,9 @@ cd "${NOTES_DIR}" main() { - command -v xclip >/dev/null 2>&1 || { echo >&2 "I require but it's not installed. It'll be in the repos, so, ~pacman -Syu xclip, aborting ."; exit 1; } OUTPUTFILE=$(getNote_onlyShowFileName) - INPUTFILE=$(xclip -o -selection clipboard) + INPUTFILE="${2}" REL_PATH=$(realpath --relative-to $(dirname $INPUTFILE) $OUTPUTFILE) ## echo $REL_PATH | xclip -selection clipboard @@ -73,4 +71,4 @@ getNote_onlyShowFileName() { } -main +main "${@}"