summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xmcomp51
1 files changed, 51 insertions, 0 deletions
diff --git a/mcomp b/mcomp
new file mode 100755
index 0000000..f4ce30c
--- /dev/null
+++ b/mcomp
@@ -0,0 +1,51 @@
+#!/bin/sh
+# mcomp [TO] - compose mail
+
+i=0
+while [ -f "snd.$i" ]; do
+	i=$((i+1))
+done
+draft="snd.$i"
+
+{
+	echo -n "To: $1"
+	[ "$#" -gt 1 ] && shift
+	for rcpt; do
+		echo -n ", $rcpt"
+	done
+	echo
+	echo "Cc: "
+	echo "Bcc: "
+	echo "Subject: "
+	cat ~/.santoku/headers 2>/dev/null
+        echo
+        echo
+	if [ -f ~/.signature ]; then
+		printf '%s\n' '-- '
+		cat ~/.signature
+	fi
+} >$draft
+
+c=e
+while :; do
+	case "$c" in
+	s|send)
+		sendmail -t <$draft && rm $draft
+		exit $?
+		;;
+	c|cancel)
+		echo "mcomp: cancelled draft $draft"
+		exit 1
+		;;
+	e|edit)
+		c=
+		if ! ${EDITOR:-vi} $draft; then
+			c=q
+		fi
+		;;
+	*)
+		echo -n "What now? ([s]end, [c]ancel, [e]dit) "
+		read -r c
+		;;
+	esac
+done