From 55212f60150387d74dcc7367f3b5638623385207 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 12 Oct 2025 09:19:47 -0500 Subject: add org-capture shell script --- dotfiles/system/.local/bin/org-capture.sh | 159 ++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100755 dotfiles/system/.local/bin/org-capture.sh (limited to 'dotfiles/system/.local/bin/org-capture.sh') diff --git a/dotfiles/system/.local/bin/org-capture.sh b/dotfiles/system/.local/bin/org-capture.sh new file mode 100755 index 0000000..1e63177 --- /dev/null +++ b/dotfiles/system/.local/bin/org-capture.sh @@ -0,0 +1,159 @@ +#!/bin/bash + +# * Defaults + +heading=" " +protocol="capture-html" +template="w" + +# * Functions + +function debug { + if [[ -n $debug ]] + then + function debug { + echo "DEBUG: $@" >&2 + } + debug "$@" + else + function debug { + true + } + fi +} +function die { + echo "$@" >&2 + exit 1 +} +function usage { + cat </{s|.*([^<]+).*|\1|i;p;q};' <<<"$html") || heading="A web page with no name" + + debug "Using heading: $heading" + +elif [[ -n $readability ]] +then + debug "Using readability" + +else + usage + echo + die "I need somethin' ta go on, Cap'n!" +fi + +# ** Check URL +# The URL shouldn't be empty + +[[ -n $url ]] || url="http://example.com" + +# ** URL-encode html + +heading=$(urlencode <<<"$heading") || die "Unable to urlencode heading." +url=$(urlencode <<<"$url") || die "Unable to urlencode URL." +html=$(urlencode <<<"$html") || die "Unable to urlencode HTML." + +# ** Send to Emacs + +emacsclient "org-protocol://$protocol?template=$template&url=$url&title=$heading&body=$html" -- cgit v1.2.3