aboutsummaryrefslogtreecommitdiffstats
path: root/bookmark_by_email.ksh
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2022-07-06 08:32:20 +0100
committerMatthew Lemon <matt@matthewlemon.com>2022-07-06 08:32:20 +0100
commite578633a77934fb70bbf0e41e5f21bcc89520e7b (patch)
tree21b845bb42adaa466cca6f55efa7068b00961d52 /bookmark_by_email.ksh
parenta58c43b474dbd764eb2e3530cf21cc77fa446ba9 (diff)
added ksh script
Diffstat (limited to 'bookmark_by_email.ksh')
-rwxr-xr-xbookmark_by_email.ksh42
1 files changed, 42 insertions, 0 deletions
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