Recently Written · git

prompt-mail

Ask mail-related questions and filter mail-related files with dmenu

git clone https://github.com/equwal/prompt-mail

Log | Files | Refs


commit b734dce254b62af63f475b2a4abbf2b2410a5814
Spenser Truex <truex@equwal.com>
2020-09-22 11:56:06 -0700

Initial commit.

 Makefile               | 20 ++++++++++++++++++++
 README                 | 17 +++++++++++++++++
 example/git-send-email |  9 +++++++++
 prompt-mail            | 19 +++++++++++++++++++
 prompt-mail.conf       |  4 ++++
 5 files changed, 69 insertions(+)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1537bda
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+BIN_PATH := /usr/local/bin
+
+default: all
+
+all:
+	@echo "Putting prompt-mail.conf in ~/.config"
+	@mkdir -p ~/.config
+	@cp prompt-mail.conf ~/.config
+	@echo "Done"
+install:
+	@echo "Putting prompt-mail in ${BIN_PATH}"
+	@cp prompt-mail ${BIN_PATH}
+	@echo "Done"
+
+uninstall:
+	@echo "Deleting ${BIN_PATH}/prompt-mail"
+	@rm -f ${BIN_PATH}/prompt-mail
+	@echo "Deleting ~/.config/prompt-mail.conf"
+	@rm -f ~/.config/prompt-mail.conf
+	@echo "Done"
diff --git a/README b/README
new file mode 100644
index 0000000..43fdc28
--- /dev/null
+++ b/README
@@ -0,0 +1,17 @@
+Prompt for email
+
+Requires:
+- dmenu
+- mail alias files
+
+Installation
+------------
+Edit prompt-mail.conf to point at any mail alias files.
+make && sudo make install
+
+
+Mail alias files are generated by mail programs like mutt. The format is:
+
+alias shorthand Some Person <someperson@example.com> # optional comment
+
+one alias per line
diff --git a/example/git-send-email b/example/git-send-email
new file mode 100755
index 0000000..41ed6a6
--- /dev/null
+++ b/example/git-send-email
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# ${PARAMETER:-WORD} expands WORD if PARAMETER is null or unset.
+PROJECT=${1:-$(find . -maxdepth 1 -mindepth 1 -type d -printf "%p\n" \ # name only
+    | sed -E s:^\.[/]:: \ # No prefix
+    | xargs echo $(pwd | sed 's:^.*/::' \ # working dir
+    | dmenu -ip "Project name:"))}
+EMAIL=${2:-$(prompt-email)}
+git send-email --subject-prefix="${PWD##*/}][PATCH" --to "$EMAIL" -1
diff --git a/prompt-mail b/prompt-mail
new file mode 100755
index 0000000..38d94bf
--- /dev/null
+++ b/prompt-mail
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+verify_email () {
+    IN=$(cat /dev/stdin)
+    echo "$IN" | grep -q '@' && echo "$IN" && return 0
+    echo "$IN Not an email." > 2 ; return 1
+}
+
+mail_addrs () {
+    cat ~/.config/prompt-mail.conf  \
+        | sed 's/^#.*$//' \
+        | xargs sed -E 's/^alias +[a-zA-Z0-9]+ // ; s/#.*$//'
+}
+
+mail_addrs \
+    | dmenu -i -p "mail address:" \
+    | verify_email
+
+
diff --git a/prompt-mail.conf b/prompt-mail.conf
new file mode 100644
index 0000000..baed0b0
--- /dev/null
+++ b/prompt-mail.conf
@@ -0,0 +1,4 @@
+# Comments have # at the beginning of the line.
+# No ~ expansion allowed.
+# Example line:
+#/home/username/.config/neomutt/aliases