From e578633a77934fb70bbf0e41e5f21bcc89520e7b Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 6 Jul 2022 08:32:20 +0100 Subject: added ksh script --- bookmark_by_email.ksh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bookmark_by_email.ksh (limited to 'bookmark_by_email.ksh') diff --git a/bookmark_by_email.ksh b/bookmark_by_email.ksh new file mode 100755 index 0000000..6acb597 --- /dev/null +++ b/bookmark_by_email.ksh @@ -0,0 +1,42 @@ +#!/bin/ksh + +# Bookmark a web page by send the contents in text format by email to 'bookmark@matthewlemon.com' +# for future indexing and searching by notmuch, etc. + +OUT_FILE=/tmp/out1.txt +OUT_FILE_P=/tmp/outpanddoc +EMAIL=bookmark@matthewlemon.com + +USAGE="f:[format]t:[title]u:[url]" +while getopts "$USAGE" optchar +do + case $optchar in + f) OUTFORMAT=$OPTARG ;; + u) URL=$OPTARG ;; + t) TITLE=$OPTARG ;; + ?) echo $USAGE; exit 2 ;; + esac +done +shift $(($OPTIND - 1)) # not sure we need this + +if ! [[ $OUTFORMAT == "md" || $OUTFORMAT == "markdown" || $OUTFORMAT == "plain" ]] +then + echo "Format must be 'md', 'markdown' or 'plain'."; exit 1; +fi + +# if [ ${#@} -gt 0 ] +# then +# echo "Non-option arguments: " "$@" +# exit 1 +# fi + +echo "$OUTFORMAT" "$URL" "$TITLE"; + +echo "$URL" > $OUT_FILE + +pandoc -f html "$URL" -t "$OUTFORMAT" -o $OUT_FILE_P + +# neomutt -s "$TITLE" -i "$(cat $OUT_FILE $OUT_FILE_P)" $EMAIL + +cat $OUT_FILE $OUT_FILE_P | mail -v -s "$TITLE" $EMAIL +rm $OUT_FILE $OUT_FILE_P -- cgit v1.2.3