imprv: reply
This commit is contained in:
16
src/main.sh
16
src/main.sh
@@ -254,7 +254,7 @@ if [ "${1:-}" = "--show-thread" ]; then
|
|||||||
--bind="$KEYS_OPEN:execute:$0 --open-part {5}" \
|
--bind="$KEYS_OPEN:execute:$0 --open-part {5}" \
|
||||||
--bind="$KEYS_FLAG:execute($0 --flag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
|
--bind="$KEYS_FLAG:execute($0 --flag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
|
||||||
--bind="$KEYS_UNFLAG:execute($0 --unflag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
|
--bind="$KEYS_UNFLAG:execute($0 --unflag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
|
||||||
--bind="$KEYS_REPLY:execute:$0 --reply {5}" \
|
--bind="$KEYS_REPLY:execute:$0 --reply message {5}" \
|
||||||
--bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" \
|
--bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" \
|
||||||
--bind="$KEYS_COMPOSE:execute:$0 --compose" \
|
--bind="$KEYS_COMPOSE:execute:$0 --compose" \
|
||||||
--bind="focus:change-preview($0 --preview-message {5})+transform-footer:printf '\033[4mMesssage parts\033[0m\n';$0 --show-message-parts {5}" \
|
--bind="focus:change-preview($0 --preview-message {5})+transform-footer:printf '\033[4mMesssage parts\033[0m\n';$0 --show-message-parts {5}" \
|
||||||
@@ -309,6 +309,7 @@ if [ "${1:-}" = "--compose" ]; then
|
|||||||
echo "From: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
echo "From: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
||||||
echo "To: $address"
|
echo "To: $address"
|
||||||
echo "Cc: "
|
echo "Cc: "
|
||||||
|
[ "$BCC_TO_SELF" ] && echo "Bcc: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
||||||
echo "Subject: "
|
echo "Subject: "
|
||||||
echo ""
|
echo ""
|
||||||
echo "Message body goes here"
|
echo "Message body goes here"
|
||||||
@@ -322,9 +323,16 @@ fi
|
|||||||
|
|
||||||
if [ "${1:-}" = "--reply" ]; then
|
if [ "${1:-}" = "--reply" ]; then
|
||||||
shift
|
shift
|
||||||
messageid="$1"
|
[ "$1" = "thread" ] && thread=1
|
||||||
|
shift
|
||||||
|
[ ! "${thread:-}" ] && messageid="$1" || messageid="$(nm_last_message_in_thread "$1")"
|
||||||
tmpfile=$(mktemp --suffix='.eml')
|
tmpfile=$(mktemp --suffix='.eml')
|
||||||
$NOTMUCH reply id:"$messageid" > "$tmpfile"
|
if [ "$BCC_TO_SELF" ]; then
|
||||||
|
$NOTMUCH reply id:"$messageid" |
|
||||||
|
awk '!f && /^From:/ { print "Bcc: "substr($0, 7); f=1 } {print}' > "$tmpfile"
|
||||||
|
else
|
||||||
|
$NOTMUCH reply id:"$messageid" > "$tmpfile"
|
||||||
|
fi
|
||||||
$EDITOR "$tmpfile"
|
$EDITOR "$tmpfile"
|
||||||
# Confirm and send
|
# Confirm and send
|
||||||
send "$tmpfile"
|
send "$tmpfile"
|
||||||
@@ -342,6 +350,7 @@ if [ "${1:-}" = "--send-test-email" ]; then
|
|||||||
{
|
{
|
||||||
echo "From: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
echo "From: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
||||||
echo "To: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
echo "To: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
||||||
|
[ "$BCC_TO_SELF" ] && echo "Bcc: $PRIMARY_NAME <$PRIMARY_EMAIL>"
|
||||||
echo "Subject: Test E-Mail from $APP_NAME version $APP_VERSION"
|
echo "Subject: Test E-Mail from $APP_NAME version $APP_VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
echo "This is a test email sent from from [$APP_NAME]($APP_WEBSITE)."
|
echo "This is a test email sent from from [$APP_NAME]($APP_WEBSITE)."
|
||||||
@@ -429,6 +438,7 @@ while true; do
|
|||||||
--bind="$KEYS_SEARCH_UNREAD:print($CMD_GOTO_UNREAD)+accept" \
|
--bind="$KEYS_SEARCH_UNREAD:print($CMD_GOTO_UNREAD)+accept" \
|
||||||
--bind="$KEYS_SEARCH_FLAGGED:print($CMD_GOTO_FLAGGED)+accept" \
|
--bind="$KEYS_SEARCH_FLAGGED:print($CMD_GOTO_FLAGGED)+accept" \
|
||||||
--bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" \
|
--bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" \
|
||||||
|
--bind="$KEYS_REPLY:execute:$0 --reply thread {4}" \
|
||||||
--bind="$KEYS_SYNC:execute($0 --sync)+reload:$0 --list-threads \"$nmquery\"" \
|
--bind="$KEYS_SYNC:execute($0 --sync)+reload:$0 --list-threads \"$nmquery\"" \
|
||||||
--bind="$KEYS_COMPOSE:execute:$0 --compose" \
|
--bind="$KEYS_COMPOSE:execute:$0 --compose" \
|
||||||
--bind="$KEYS_GOTO_FIRST:first" \
|
--bind="$KEYS_GOTO_FIRST:first" \
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ if [ ! "${CONFIG_LOADED:-}" ]; then
|
|||||||
|
|
||||||
PRIMARY_NAME=${PRIMARY_NAME:-$($NOTMUCH config get user.name)}
|
PRIMARY_NAME=${PRIMARY_NAME:-$($NOTMUCH config get user.name)}
|
||||||
PRIMARY_EMAIL=${PRIMARY_EMAIL:-$($NOTMUCH config get user.primary_email)}
|
PRIMARY_EMAIL=${PRIMARY_EMAIL:-$($NOTMUCH config get user.primary_email)}
|
||||||
|
BCC_TO_SELF=${BCC_TO_SELF:-}
|
||||||
|
|
||||||
if [ ! "${SMTPLOGFILE:-}" ]; then
|
if [ ! "${SMTPLOGFILE:-}" ]; then
|
||||||
SMTPLOGFILE=$(mktemp)
|
SMTPLOGFILE=$(mktemp)
|
||||||
trap 'rm -f "$SMTPLOGFILE"' EXIT INT
|
trap 'rm -f "$SMTPLOGFILE"' EXIT INT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PRIMARY_NAME PRIMARY_EMAIL SET_TERMINAL_TITLE SMTPLOGFILE
|
export PRIMARY_NAME PRIMARY_EMAIL BCC_TO_SELF SET_TERMINAL_TITLE SMTPLOGFILE
|
||||||
|
|
||||||
export CONFIG_LOADED=1
|
export CONFIG_LOADED=1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ nm_new() {
|
|||||||
# Print the message id of the last message within a thread.
|
# Print the message id of the last message within a thread.
|
||||||
# @argument $1: thread id
|
# @argument $1: thread id
|
||||||
nm_last_message_in_thread() {
|
nm_last_message_in_thread() {
|
||||||
# TODO: We may be smarter here that just incorporating excluded messages
|
$NOTMUCH search --output=messages --sort=newest-first --limit=1 thread:"$1" | sed 's/^...//'
|
||||||
$NOTMUCH search --output=messages --sort=oldest-first --offset=-1 thread:"$1" | sed 's/^...//'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print the header of a message (with trailing empty line)
|
# Print the header of a message (with trailing empty line)
|
||||||
|
|||||||
@@ -43,17 +43,3 @@ multiprompt() {
|
|||||||
--bind="ctrl-c,esc,ctrl-q:" \
|
--bind="ctrl-c,esc,ctrl-q:" \
|
||||||
--color='border:yellow,header:yellow' | head -1 || true
|
--color='border:yellow,header:yellow' | head -1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# ASCII-encode address
|
|
||||||
# asciiaddress() {
|
|
||||||
# firstword=1
|
|
||||||
# for word in $*; do
|
|
||||||
# [ "${firstword:-}" ] || echo -n ' ' && firstword=
|
|
||||||
# case $word in
|
|
||||||
# *[![:cntrl:][:print:]]*) echo -n $word ;;
|
|
||||||
# *) return 0 ;;
|
|
||||||
# esac
|
|
||||||
# isascii "$word" && echo -n "$word" || echo -n "=?UTF-8?B?$(echo -n "$word" | base64)?="
|
|
||||||
# done
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user