improved POSIX

This commit is contained in:
2026-03-17 14:00:07 +01:00
parent ea16fb03d5
commit ce9f16e293
6 changed files with 22 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
if [ ! "${HISTORY_LOADED:-}" ]; then
export NMFHIST=$(mktemp)
NMFHIST="$(mktemp)"
export NMFHIST
touch "$NMFHIST"
trap 'rm -f "$NMFHIST"' EXIT INT

View File

@@ -24,6 +24,7 @@ if [ ! "${KEYS_LOADED:-}" ]; then
KEYS_COMPOSE="ctrl-n"
KEYS_VIEW_LOGS="alt-0"
KEYS_SYNC="ctrl-s"
KEYS_GOTO_FIRST="home"
# Preview window
KEYS_PREVIEW_DOWN="alt-j"
@@ -52,12 +53,12 @@ if [ ! "${KEYS_LOADED:-}" ]; then
KEYS_ENTER_ALTERNATIVE KEYS_CYCLE_DISPLAY KEYS_VIEW_SOURCE \
KEYS_HTML_PREVIEW KEYS_TAG_ADD KEYS_TAG_REMOVE KEYS_ARCHIVE KEYS_DELETE \
KEYS_FLAG KEYS_UNFLAG KEYS_OPEN KEYS_REPLY KEYS_COMPOSE KEYS_VIEW_LOGS \
KEYS_SYNC KEYS_PREVIEW_DOWN KEYS_PREVIEW_UP KEYS_PREVIEW_DOWN_HP \
KEYS_SYNC KEYS_GOTO_FIRST KEYS_PREVIEW_DOWN KEYS_PREVIEW_UP KEYS_PREVIEW_DOWN_HP \
KEYS_PREVIEW_UP_HP KEYS_PREVIEW_TOGGLE_SIZE KEYS_SEARCH_TAG_REPLCE \
KEYS_SEARCH_TAG_APPEND KEYS_SEARCH_FROM_REPLCE KEYS_SEARCH_FROM_APPEND \
KEYS_SEARCH_TO_REPLCE KEYS_SEARCH_TO_APPEND KEYS_SEARCH_EDIT_QUERY \
KEYS_SEARCH_DELETED KEYS_SEARCH_INBOX KEYS_SEARCH_UNREAD \
KEYS_SEARCH_FLAGGED
KEYS_SEARCH_FLAGGED KEYS_PURGE_ALL
export KEYS_LOADED=1
fi

View File

@@ -11,7 +11,6 @@
# @argument #3: if set, then the HTML messages will be taken
preview_message() {
[ "$1" = "id" ] && messageid="$2" || messageid="$(nm_last_message_in_thread "$2")"
parts="$(nm_message_parts "$messageid")"
html="${3:-}"
nr="$(nm_message_part_nr "$messageid" "$html")"
[ ! "$nr" ] && [ ! "$html" ] && html="html" && nr="$(nm_message_part_nr "$messageid" "html")"

View File

@@ -2,12 +2,12 @@
# @argument $1: Path to email file
# @argument $2: if set, don't prompt the user (optional)
send() {
if [ ! "${2:-}" ] && ! ynprompt "Do you want to send this email?" "$($CATEMAIL $tmpfile)"; then
if [ ! "${2:-}" ] && ! ynprompt "Do you want to send this email?" "$($CATEMAIL "$tmpfile")"; then
return
fi
$MSMTP -t --read-envelope-from -X "$SMTPLOGFILE" < "$1" >/dev/null 2>&1 || true
log=$(tail -1 "$SMTPLOGFILE")
if [ "${2:-}" ] || echo -n "$log" | grep -q '\bsmtpstatus=250\b'; then
if [ "${2:-}" ] || printf '%s' "$log" | grep -q '\bsmtpstatus=250\b'; then
return
fi
# Handle errors

View File

@@ -5,7 +5,7 @@
# @argument $2: Content to show in preview window
# @return: 0 if the user answered "yes" and 1 otherwise.
ynprompt() {
return $(printf '0 \033[32myes\033[0m\n1 \033[31mno\033[0m\n' |
return "$(printf '0 \033[32myes\033[0m\n1 \033[31mno\033[0m\n' |
$FZF \
--sync \
--bind='start:pos(2)' \
@@ -19,7 +19,7 @@ ynprompt() {
--with-nth=2.. \
--accept-nth=1 \
--header-border='line' \
--color='border:yellow,header:yellow')
--color='border:yellow,header:yellow')"
}
# This prompts the user for a series of options.