From 1c1f4aba4e47a441e14cf12ff735f39202a121a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Fri, 20 Mar 2026 10:03:49 +0100 Subject: [PATCH] improved: smooth and file info --- src/main.sh | 43 +++++++++++++++++++++++++++++++------------ src/sh/keys.sh | 4 ++-- src/sh/tools.sh | 20 +++++++++++++++++--- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/main.sh b/src/main.sh index 9316ee9..8446d50 100755 --- a/src/main.sh +++ b/src/main.sh @@ -44,6 +44,25 @@ set -eu # send emails . "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 shift nmquery="$1" @@ -124,7 +143,7 @@ if [ "${1:-}" = "--open-part" ]; then [ "$res" ] || exit tmpfile=$(mktemp) 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? open "$tmpfile" >/dev/null 2>/dev/stdout fi @@ -250,11 +269,11 @@ if [ "${1:-}" = "--show-thread" ]; then --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_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_DELETE:execute($0 --delete 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-silent($0 --delete message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --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_UNFLAG:execute($0 --unflag 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-silent($0 --unflag message {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \ --bind="$KEYS_REPLY:execute:$0 --reply message {5}" \ --bind="$KEYS_VIEW_LOGS:execute:$0 --view-logs" \ --bind="$KEYS_COMPOSE:execute:$0 --compose" \ @@ -282,9 +301,9 @@ if [ "${1:-}" = "--list-deleted" ]; then --bind="$KEYS_DOWN_HP:half-page-down" \ --bind="$KEYS_UP_HP:half-page-up" \ --bind="$KEYS_ENTER:" \ - --bind="$KEYS_PURGE_ALL:select-all+execute($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_ENTER_ALTERNATIVE:execute($0 --undelete {+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-silent($0 --purge {+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" exit fi @@ -431,10 +450,10 @@ while true; do --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_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_DELETE:execute($0 --delete thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ - --bind="$KEYS_FLAG:execute($0 --flag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ - --bind="$KEYS_UNFLAG:execute($0 --unflag 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-silent($0 --delete 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-silent($0 --unflag thread {+4})+reload:$0 --list-threads \"$nmquery\"" \ --bind="$KEYS_SEARCH_DELETED:execute:$0 --list-deleted" \ --bind="$KEYS_SEARCH_INBOX:print($CMD_GOTO_INBOX)+accept" \ --bind="$KEYS_SEARCH_UNREAD:print($CMD_GOTO_UNREAD)+accept" \ diff --git a/src/sh/keys.sh b/src/sh/keys.sh index a981308..2028bf7 100644 --- a/src/sh/keys.sh +++ b/src/sh/keys.sh @@ -17,8 +17,8 @@ if [ ! "${KEYS_LOADED:-}" ]; then export KEYS_TAG_REMOVE="alt--" export KEYS_ARCHIVE="ctrl-a" export KEYS_DELETE="ctrl-delete" - export KEYS_FLAG="ctrl-x" - export KEYS_UNFLAG="ctrl-alt-x" + export KEYS_FLAG="ctrl-f" + export KEYS_UNFLAG="ctrl-alt-f" export KEYS_OPEN="ctrl-o" export KEYS_REPLY="ctrl-r" export KEYS_COMPOSE="ctrl-n" diff --git a/src/sh/tools.sh b/src/sh/tools.sh index 24d6ed8..b599722 100644 --- a/src/sh/tools.sh +++ b/src/sh/tools.sh @@ -37,12 +37,14 @@ if [ ! "${TOOLS_LOADED:-}" ]; then CAT="batcat" fi 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} + CATMD=${CAT:+$CAT -l markdown --style=plain --color=always} CATMD=${CATMD:-cat} + CATLOG=${CAT:+$CAT -l log --style=plain --color=always} 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 PANDOC="pandoc --from html --to markdown_strict-raw_html" @@ -50,5 +52,17 @@ if [ ! "${TOOLS_LOADED:-}" ]; then PANDOC=${PANDOC:-cat} 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 fi