improved: smooth and file info

This commit is contained in:
2026-03-20 10:03:49 +01:00
parent dfea7f301f
commit 1c1f4aba4e
3 changed files with 50 additions and 17 deletions
+31 -12
View File
@@ -44,6 +44,25 @@ set -eu
# send emails # send emails
. "sh/send.sh" . "sh/send.sh"
if [ "${1:-}" = "--preview-file-info" ]; then
shift
f="$1"
{
file -zb "$f"
du -sh "$f"
echo ""
case "$(file --brief --mime-type "$f")" in
"application/pdf")
[ "$PDFINFO" ] && $PDFINFO "$f"
;;
"text/html")
[ "$HTMLQ" ] && echo "title: $($HTMLQ -t -- title < "$f")"
;;
esac
} | $CATFINFO
exit
fi
if [ "${1:-}" = "--list-threads" ]; then if [ "${1:-}" = "--list-threads" ]; then
shift shift
nmquery="$1" nmquery="$1"
@@ -124,7 +143,7 @@ if [ "${1:-}" = "--open-part" ]; then
[ "$res" ] || exit [ "$res" ] || exit
tmpfile=$(mktemp) tmpfile=$(mktemp)
nm_message_get_part "$messageid" "$res" > "$tmpfile" nm_message_get_part "$messageid" "$res" > "$tmpfile"
if ynprompt "Are you sure you want to open this file?" "$(ls -lh "$tmpfile")\n$(file -b "$tmpfile")"; then if ynprompt "Are you sure you want to open this file?" "$($0 --preview-file-info "$tmpfile")"; then
# TODO: should we clean up at some point? # TODO: should we clean up at some point?
open "$tmpfile" >/dev/null 2>/dev/stdout open "$tmpfile" >/dev/null 2>/dev/stdout
fi fi
@@ -250,11 +269,11 @@ if [ "${1:-}" = "--show-thread" ]; then
--bind="$KEYS_HTML_PREVIEW:change-preview:$0 --preview-html-message {5}" \ --bind="$KEYS_HTML_PREVIEW:change-preview:$0 --preview-html-message {5}" \
--bind="$KEYS_TAG_ADD:execute($0 --tag-modify message add {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --bind="$KEYS_TAG_ADD:execute($0 --tag-modify message add {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="$KEYS_TAG_REMOVE:execute($0 --tag-modify message del {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --bind="$KEYS_TAG_REMOVE:execute($0 --tag-modify message del {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="$KEYS_ARCHIVE:execute($0 --archive message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --bind="$KEYS_ARCHIVE:execute-silent($0 --archive message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="$KEYS_DELETE:execute($0 --delete message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --bind="$KEYS_DELETE:execute-silent($0 --delete message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--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-silent($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-silent($0 --unflag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="$KEYS_REPLY:execute:$0 --reply message {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" \
@@ -282,9 +301,9 @@ if [ "${1:-}" = "--list-deleted" ]; then
--bind="$KEYS_DOWN_HP:half-page-down" \ --bind="$KEYS_DOWN_HP:half-page-down" \
--bind="$KEYS_UP_HP:half-page-up" \ --bind="$KEYS_UP_HP:half-page-up" \
--bind="$KEYS_ENTER:" \ --bind="$KEYS_ENTER:" \
--bind="$KEYS_PURGE_ALL:select-all+execute($0 --purge {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \ --bind="$KEYS_PURGE_ALL:select-all+execute-silent($0 --purge {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \
--bind="$KEYS_DELETE:execute($0 --purge {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \ --bind="$KEYS_DELETE:execute-silent($0 --purge {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \
--bind="$KEYS_ENTER_ALTERNATIVE:execute($0 --undelete {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \ --bind="$KEYS_ENTER_ALTERNATIVE:execute-silent($0 --undelete {+4})+reload:$0 --list-threads \"tag:$TAG_DEL\"" \
--bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" --bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs"
exit exit
fi fi
@@ -431,10 +450,10 @@ while true; do
--bind="$KEYS_HTML_PREVIEW:change-preview:$0 --preview-html-thread {4}" \ --bind="$KEYS_HTML_PREVIEW:change-preview:$0 --preview-html-thread {4}" \
--bind="$KEYS_TAG_ADD:execute($0 --tag-modify thread add {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_TAG_ADD:execute($0 --tag-modify thread add {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_TAG_REMOVE:execute($0 --tag-modify thread del {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_TAG_REMOVE:execute($0 --tag-modify thread del {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_ARCHIVE:execute($0 --archive thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_ARCHIVE:execute-silent($0 --archive thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_DELETE:execute($0 --delete thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_DELETE:execute-silent($0 --delete thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_FLAG:execute($0 --flag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_FLAG:execute-silent($0 --flag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_UNFLAG:execute($0 --unflag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_UNFLAG:execute-silent($0 --unflag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="$KEYS_SEARCH_DELETED:execute:$0 --list-deleted" \ --bind="$KEYS_SEARCH_DELETED:execute:$0 --list-deleted" \
--bind="$KEYS_SEARCH_INBOX:print($CMD_GOTO_INBOX)+accept" \ --bind="$KEYS_SEARCH_INBOX:print($CMD_GOTO_INBOX)+accept" \
--bind="$KEYS_SEARCH_UNREAD:print($CMD_GOTO_UNREAD)+accept" \ --bind="$KEYS_SEARCH_UNREAD:print($CMD_GOTO_UNREAD)+accept" \
+2 -2
View File
@@ -17,8 +17,8 @@ if [ ! "${KEYS_LOADED:-}" ]; then
export KEYS_TAG_REMOVE="alt--" export KEYS_TAG_REMOVE="alt--"
export KEYS_ARCHIVE="ctrl-a" export KEYS_ARCHIVE="ctrl-a"
export KEYS_DELETE="ctrl-delete" export KEYS_DELETE="ctrl-delete"
export KEYS_FLAG="ctrl-x" export KEYS_FLAG="ctrl-f"
export KEYS_UNFLAG="ctrl-alt-x" export KEYS_UNFLAG="ctrl-alt-f"
export KEYS_OPEN="ctrl-o" export KEYS_OPEN="ctrl-o"
export KEYS_REPLY="ctrl-r" export KEYS_REPLY="ctrl-r"
export KEYS_COMPOSE="ctrl-n" export KEYS_COMPOSE="ctrl-n"
+17 -3
View File
@@ -37,12 +37,14 @@ if [ ! "${TOOLS_LOADED:-}" ]; then
CAT="batcat" CAT="batcat"
fi fi
CATEMAIL=${CAT:+$CAT -l email --style=plain --color=always} CATEMAIL=${CAT:+$CAT -l email --style=plain --color=always}
CATMD=${CAT:+$CAT -l markdown --style=plain --color=always}
CATLOG=${CAT:+$CAT -l log --style=plain --color=always}
CATEMAIL=${CATEMAIL:-cat} CATEMAIL=${CATEMAIL:-cat}
CATMD=${CAT:+$CAT -l markdown --style=plain --color=always}
CATMD=${CATMD:-cat} CATMD=${CATMD:-cat}
CATLOG=${CAT:+$CAT -l log --style=plain --color=always}
CATLOG=${CATLOG:-cat} CATLOG=${CATLOG:-cat}
export CATEMAIL CATMD CATLOG CATFINFO=${CAT:+$CAT -l yaml --style=plain --color=always}
CATFINFO=${CATFINFO:-cat}
export CATEMAIL CATMD CATLOG CATFINFO
if command -v "pandoc" >/dev/null; then if command -v "pandoc" >/dev/null; then
PANDOC="pandoc --from html --to markdown_strict-raw_html" PANDOC="pandoc --from html --to markdown_strict-raw_html"
@@ -50,5 +52,17 @@ if [ ! "${TOOLS_LOADED:-}" ]; then
PANDOC=${PANDOC:-cat} PANDOC=${PANDOC:-cat}
export PANDOC export PANDOC
if command -v "pdfinfo" >/dev/null; then
PDFINFO="pdfinfo"
fi
PDFINFO=${PDFINFO:-}
export PDFINFO
if command -v "htmlq" >/dev/null; then
HTMLQ="htmlq"
fi
HTMLQ=${HTMLQ:-}
export HTMLQ
export TOOLS_LOADED=1 export TOOLS_LOADED=1
fi fi