Compare commits

...

7 Commits

Author SHA1 Message Date
8a0c8bc2d7 feat: tag manipulation 2026-03-12 18:17:03 +01:00
1453fdb3ad feat: open attachments with ctrl-o 2026-03-12 15:32:37 +01:00
eb8f4574bf feat: html rendering 2026-03-12 14:52:29 +01:00
60f763df19 feat: configfile 2026-03-12 08:24:13 +01:00
3210a8bbcf imprv: colors 2026-03-12 08:17:19 +01:00
7653f052b7 alt-v: view source of email 2026-03-11 23:16:19 +01:00
f703bc487a ctrl-d,ctrl-u keys 2026-03-11 22:58:04 +01:00
14 changed files with 381 additions and 113 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
nmf
.tags

View File

@@ -1,49 +0,0 @@
BEGIN {
RS = "\x0c"
FS = "\n"
}
/^message}/ {
mheader = header
mpart = part
mparts = parts
level = 0
multipart = ""
header = ""
part = ""
parts = ""
}
/^header{/ {
header = $0
}
/^part}/ {
level--
}
/^part{/ {
parts = sprintf("%s\n%"(2*level)"s%s", parts, "", substr($1, 7))
level++
}
# /^part{ ID: [[:digit:]]+, Content-type: multipart\/alternative/ {
# multipart = "alternative"
# }
# /^part{ ID: [[:digit:]]+, Content-type: multipart\/mixed/ {
# multipart = "mixed"
# }
/^part{ ID: [[:digit:]]+, Content-type: text\/plain/ {
part = $0
}
END {
split(mheader, a, "\n")
delete a[1]
# delete a[2]
for (line in a) {
print a[line]
}
split(mpart, a, "\n")
delete a[1]
for (line in a) {
print a[line]
}
print "Parts:"mparts
}

13
src/awk/messageheader.awk Normal file
View File

@@ -0,0 +1,13 @@
BEGIN {
RS = "\x0c"
FS = "\n"
}
/^header{/ {
split($0, a, "\n")
delete a[1]
delete a[2]
for (line in a)
print a[line]
exit
}

12
src/awk/messageparts.awk Normal file
View File

@@ -0,0 +1,12 @@
BEGIN {
RS = "\x0c"
FS = "\n"
}
/^(part|attachment)}/ {
level--
}
/^(part|attachment){/ {
printf "%"(2*level)"s%s\n", "", substr($1, index($1, "ID"))
level++
}

14
src/awk/partnr.awk Normal file
View File

@@ -0,0 +1,14 @@
# Return the part number of the first text/plain part, or, if the variable
# `html` is set, of the first text/html part.
BEGIN {
RS = "\x0c"
FS = "\n"
}
/^part{.*Content-type: text\// {
match($1, "ID: ([[:digit:]]+).* Content-type: text/([[:alpha:]]+)", a)
if ((html && a[2] == "html") || (!html && a[2] == "plain")) {
print a[1]
exit
}
}

View File

@@ -3,11 +3,6 @@ BEGIN {
FS = "\n"
}
# message{ id:eb93d845-6fc7-4181-9848-7411ed999b3c@indyfac.ch depth:0 match:1 excluded:0 filename:/home/amin/.email/indyfac/INBOX/cur/1773225033.821818_4.fredkin,U=4172:2,S
# header{
# lobo loco <loboloco@indyfac.ch> (Today 10:12) (inbox)
/^message{/ {
id = ""
depth = -1

View File

@@ -5,6 +5,9 @@ set -eu
# Application info
. "sh/info.sh"
# Configuration
. "sh/config.sh"
# Theme
. "sh/theme.sh"
@@ -14,47 +17,71 @@ set -eu
# tools
. "sh/tools.sh"
# history
# query history
. "sh/history.sh"
__notmuch_search() {
$NOTMUCH search "$*" \
| sed "s/^thread:\([[:xdigit:]]\+\)\s\+\([^[]\+\)\s\+\[\([^]]\+\)\]\([^;]*\); \(.*\) (\([^(]*\))$/${COLDATE}\2${COLRESET}\t${COLCNTS}\3${COLRESET}\t${COLFROM}\4${COLRESET}\t${COLSUBJ}\5${COLRESET}\t${COLTAGS}\6${COLRESET}\t\1/" \
| column -s "$(printf '\t')" -t -l 3 -R 1,2
}
# notmuch functions
. "sh/notmuch.sh"
__notmuch_thread() {
$NOTMUCH show thread:"$1" \
| awk "$AWK_THREADOVERVIEW" \
| sed "s/^\(\S*\)\t\([^\t]*\)\t\(.*\) (\([^()]*\)) (\([^()]*\))$/${COLFROM}\3${COLRESET}\t${COLSUBJ}\2${COLRESET}\t${COLDATE}\4${COLRESET}\t${COLTAGS}\5${COLRESET}\t\1/"
}
# list generators
. "sh/lists.sh"
__notmuch_list_tags() {
$NOTMUCH search --output=tags tag:/./
}
# preview functions
. "sh/preview.sh"
__notmuch_list_address() {
$NOTMUCH address '*'
}
if [ "${1:-}" = "--list-threads" ]; then
shift
nmquery="$1"
list_threads "$nmquery"
exit
fi
if [ "${1:-}" = "--list-messages-in-thread" ]; then
shift
thread="$1"
list_messages_in_thread "$thread"
exit
fi
if [ "${1:-}" = "--preview-thread" ]; then
shift
thread="$1"
$NOTMUCH show thread:$thread \
| awk "$AWK_LASTMESSAGEINTHREAD" \
| tail -n +2 \
| $CAT
threadid="$1"
preview_message "thread" "$threadid"
exit
fi
if [ "${1:-}" = "--preview-html-thread" ]; then
shift
threadid="$1"
preview_message "thread" "$threadid" "html"
exit
fi
if [ "${1:-}" = "--preview-message" ]; then
shift
messageid="$1"
$NOTMUCH show id:$messageid \
| awk "$AWK_LASTMESSAGEINTHREAD" \
| tail -n +2 \
| $CAT
preview_message "id" "$messageid"
exit
fi
if [ "${1:-}" = "--preview-html-message" ]; then
shift
messageid="$1"
preview_message "id" "$messageid" "html"
exit
fi
if [ "${1:-}" = "--view-source" ]; then
shift
messageid="$1"
less $($NOTMUCH search --output=files id:$messageid)
exit
fi
if [ "${1:-}" = "--show-message-parts" ]; then
shift
messageid="$1"
nm_message_parts "$messageid"
exit
fi
@@ -63,23 +90,124 @@ FZF_DEFAULT_PREVIEW_WINDOW="right,80,border-line,wrap-word"
FZF_ALTERNATE_PREVIEW_WINDOW="bottom,80%,border-line,wrap-word"
FZF_DEFAULT_THREAD_LINE="{1} {3} ({4})"
if [ "${1:-}" = "--open-part" ]; then
shift
messageid="$1"
res=$(nm_message_parts "$messageid" | awk '{print NR"\t"$0}' | $FZF \
--raw \
--reverse \
--wrap=word \
--delimiter="$(printf '\t')" \
--with-nth=2 \
--accept-nth=1 \
--margin='30%' \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--bind='page-up:preview-half-page-up,page-down:preview-half-page-down' \
--bind="ctrl-h,backward-eof:abort" || true)
[ "$res" ] || exit
tmpfile=$(mktemp)
nm_message_get_part "$messageid" "$res" > "$tmpfile"
file "$tmpfile"
while true; do
printf "Are you sure you want to open \"%s\"? (yes/no): " "$tmpfile" >/dev/tty
read -r yn
case $yn in
"yes")
open "$tmpfile" >/dev/null 2>/dev/stdout
printf "Press <enter> to continue." >/dev/tty
read -r tmp
break
;;
"no")
break
;;
*)
echo "Please answer \"yes\" or \"no\"." >/dev/tty
;;
esac
done
rm -f "$tmpfile"
exit
fi
if [ "${1:-}" = "--archive" ]; then
shift
[ "$1" = "thread" ] && thread=1
shift
[ "${thread:-}" ] && field="thread" || field="id"
query="$(echo "$@" | sed "s/\s\(\S\)/ $field:\1/g" | sed "s/^/$field:/")"
nm_tag "-inbox" "$query"
nm_tag "-unread" "$query"
exit
fi
if [ "${1:-}" = "--delete" ]; then
shift
[ "$1" = "thread" ] && thread=1
shift
[ "${thread:-}" ] && field="thread" || field="id"
query="$(echo "$@" | sed "s/\s\(\S\)/ $field:\1/g" | sed "s/^/$field:/")"
nm_tag "-inbox" "$query"
nm_tag "+del" "$query"
exit
fi
if [ "${1:-}" = "--tag-modify" ]; then
shift
[ "$1" = "thread" ] && thread=1
shift
[ "$1" = "add" ] && sign=+ || sign=-
shift
[ "${thread:-}" ] && field="thread" || field="id"
query="$(echo "$@" | sed "s/\s\(\S\)/ $field:\1/g" | sed "s/^/$field:/")"
if [ "$sign" = "+" ]; then
tagquery=""
label_text="Add tag"
else
tagquery="$query"
label_text="Remove tag"
fi
res=$(list_tags "$tagquery" | $FZF \
--color="border:$ANSICOLORTAGS" \
--color="label:$ANSICOLORTAGS" \
--tac \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--margin='20%' \
--bind='enter:accept-or-print-query' \
--border=double \
--border-label=" $label_text " || true)
[ "$res" ] || exit
nm_tag "$sign$res" "$query"
exit
fi
if [ "${1:-}" = "--show-thread" ]; then
shift
thread="$1"
res=$(__notmuch_thread "$thread" | fzf \
res=$(list_messages_in_thread "$thread" | $FZF \
--raw \
--ansi \
--reverse \
--multi \
--delimiter="$(printf '\t')" \
--with-nth="$FZF_DEFAULT_THREAD_LINE" \
--bind="ctrl-r:reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="alt-s:change-with-nth({1} {2} {3} ({4})|$FZF_DEFAULT_THREAD_LINE)" \
--accept-nth=5 \
--bind='alt-j:preview-down,alt-k:preview-up' \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--bind='page-up:preview-half-page-up,page-down:preview-half-page-down' \
--bind="enter:" \
--bind="ctrl-h,backward-eof:abort" \
--bind="alt-/:change-preview-window($FZF_ALTERNATE_PREVIEW_WINDOW|$FZF_DEFAULT_PREVIEW_WINDOW)" \
--bind="alt-v:execute:$0 --view-source {5}" \
--bind="alt-h:change-preview:$0 --preview-html-message {5}" \
--bind="alt-+:execute($0 --tag-modify message add {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="alt--:execute($0 --tag-modify message del {+5})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="alt-enter:execute($0 --archive message {+4})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="alt-delete:execute($0 --delete message {+4})+reload:$0 --list-messages-in-thread \"$thread\"" \
--bind="focus:change-preview($0 --preview-message {5})+transform-footer:printf '\033[4mMesssage parts\033[0m\n';$0 --show-message-parts {5}" \
--bind="ctrl-o:execute:$0 --open-part {5}" \
--preview="$0 --preview-message {5}" \
--preview-window="$FZF_DEFAULT_PREVIEW_WINDOW" || true)
exit
@@ -97,14 +225,15 @@ CMD_EDIT_QUERY="edit-query"
while true; do
nmquery="${nmquery:-tag:inbox}"
[ "$(tail -1 "$NMFHIST")" = "$nmquery" ] || echo "$nmquery" >> "$NMFHIST"
cmd=$(__notmuch_search "$nmquery" | fzf \
cmd=$(list_threads "$nmquery" | $FZF \
--header-first \
--header="Query: $nmquery" \
--ansi \
--tiebreak=index \
--reverse \
--multi \
--delimiter="$(printf '\t')" \
--with-nth="{1} {2} ({3})" \
--bind="ctrl-r:reload:$0 --list-threads \"$nmquery\"" \
--bind="alt-t:print($CMD_SEARCH_TAG$NWSRCH)+accept" \
--bind="alt-T:print($CMD_SEARCH_TAG$APPEND)+accept" \
--bind="alt-s:print($CMD_SEARCH_ADDRESS$ADDRESS_FROM$NWSRCH)+accept" \
@@ -113,39 +242,49 @@ while true; do
--bind="alt-R:print($CMD_SEARCH_ADDRESS$ADDRESS_TO$APPEND)+accept" \
--bind="alt-q:print($CMD_EDIT_QUERY)+accept" \
--bind='alt-j:preview-down,alt-k:preview-up' \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--bind='page-up:preview-half-page-up,page-down:preview-half-page-down' \
--bind="enter,ctrl-l:execute:$0 --show-thread {4}" \
--bind="enter,ctrl-l:execute($0 --show-thread {4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="alt-/:change-preview-window($FZF_ALTERNATE_PREVIEW_WINDOW|$FZF_DEFAULT_PREVIEW_WINDOW)" \
--bind="alt-h:change-preview:$0 --preview-html-thread {4}" \
--bind="alt-+:execute($0 --tag-modify thread add {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="alt--:execute($0 --tag-modify thread del {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="alt-enter:execute($0 --archive thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="alt-delete:execute($0 --delete thread {+4})+reload:$0 --list-threads \"$nmquery\"" \
--bind="focus:change-preview:$0 --preview-thread {4}" \
--preview="$0 --preview-thread {4}" \
--preview-window="$FZF_DEFAULT_PREVIEW_WINDOW" | head -1 || true)
[ -n "$cmd" ] || exit 0
case "$cmd" in
$CMD_SEARCH_TAG*)
tag=$(__notmuch_list_tags | fzf \
--ansi \
--cycle \
tag=$(list_tags | $FZF \
--color="border:$ANSICOLORTAGS" \
--color="label:$ANSICOLORTAGS" \
--tac \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--margin='20%' \
--bind='enter:accept-or-print-query' \
--border=double \
--border-label='Select tag' || true)
--border-label=" Select tag " || true)
[ -n "$tag" ] || continue
[ "$cmd" = "$CMD_SEARCH_TAG$APPEND" ] && nmquery="$nmquery and tag:$tag" || nmquery="tag:$tag"
;;
$CMD_SEARCH_ADDRESS*)
case "$cmd" in
*$ADDRESS_FROM*)
label_text='Select sender'
label_text=" Select sender "
field='from'
;;
*)
label_text='Select recipient'
label_text=" Select recipient "
field='to'
;;
esac
address=$(__notmuch_list_address | fzf \
--ansi \
address=$(list_addresses | $FZF \
--color="border:$ANSICOLORFROM" \
--color="label:$ANSICOLORFROM" \
--tiebreak=index \
--cycle \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--margin='20%' \
--bind='enter:accept-or-print-query' \
--border=double \
@@ -161,9 +300,11 @@ while true; do
esac
;;
$CMD_EDIT_QUERY*)
nmquery=$(fzf \
--ansi \
nmquery=$(list_query_history | $FZF \
--color="border:$ANSICOLORSUBJ" \
--color="label:$ANSICOLORSUBJ" \
--tac \
--bind='ctrl-d:half-page-down,ctrl-u:half-page-up' \
--margin='20%' \
--query="$nmquery" \
--disabled \
@@ -171,7 +312,7 @@ while true; do
--prompt="Query: " \
--bind='focus:replace-query' \
--border=double \
--border-label='Query history' < "$NMFHIST" | head -1 || true)
--border-label=' Query history ' | head -1 || true)
;;
*)
;;

View File

@@ -1,11 +1,4 @@
if [ ! "${AWK_LOADED:-}" ]; then
AWK_LASTMESSAGEINTHREAD=$(
cat <<'EOF'
@@include awk/lastmessageinthread.awk
EOF
)
export AWK_LASTMESSAGEINTHREAD
AWK_THREADOVERVIEW=$(
cat <<'EOF'
@@include awk/threadoverview.awk
@@ -13,5 +6,26 @@ EOF
)
export AWK_THREADOVERVIEW
AWK_MESSAGEHEADER=$(
cat <<'EOF'
@@include awk/messageheader.awk
EOF
)
export AWK_MESSAGEHEADER
AWK_MESSAGEPARTS=$(
cat <<'EOF'
@@include awk/messageparts.awk
EOF
)
export AWK_MESSAGEPARTS
AWK_PARTNR=$(
cat <<'EOF'
@@include awk/partnr.awk
EOF
)
export AWK_PARTNR
export AWK_LOADED=1
fi

11
src/sh/config.sh Normal file
View File

@@ -0,0 +1,11 @@
# Main application configuration. This application does not require a
# configuration file. However, a configuration file may be stored as
# `CONFIGFILE_DEFAULT`. If that file exists, it will be sourced. The path to
# the file may be overwritten by specifying the environment variable
# `CONFIGFILE`. If a configuration file is specified, then it must also exist.
# A configuration file comprises the specification of environment variables
# that are allowed to be set.
CONFIGFILE_DEFAULT="${XDG_CONFIG_HOME:-"$HOME/.config"}/$APP_NAME/config"
CONFIGFILE="${CONFIGFILE:-"$CONFIGFILE_DEFAULT"}"
[ "$CONFIGFILE" != "$CONFIGFILE_DEFAULT" ] && [ ! -f "$CONFIGFILE" ] && err "The configuration file manually specified with the environment variable CONFIGFILE=($CONFIGFILE) does not exist." && exit 1
[ -f "$CONFIGFILE" ] && . "$CONFIGFILE"

35
src/sh/lists.sh Normal file
View File

@@ -0,0 +1,35 @@
# These functions generate the lists that are fed into fzf
# List the messages within a thread
# @argument $1: thread id
list_messages_in_thread() {
$NOTMUCH show thread:"$1" \
| awk "$AWK_THREADOVERVIEW" \
| sed "s/^\(\S*\)\t\([^\t]*\)\t\(.*\) (\([^()]*\)) (\([^()]*\))$/${COLFROM}\3${COLRESET}\t${COLSUBJ}\2${COLRESET}\t${COLDATE}\4${COLRESET}\t${COLTAGS}\5${COLRESET}\t\1/"
}
# List all threads that match a query
# @argument $1: query
list_threads() {
$NOTMUCH search "$1" \
| sed "s/^thread:\([[:xdigit:]]\+\)\s\+\([^[]\+\)\s\+\[\([^]]\+\)\]\([^;]*\); \(.*\) (\([^(]*\))$/${COLDATE}\2${COLRESET}\t${COLCNTS}\3${COLRESET}\t${COLFROM}\4${COLRESET}\t${COLSUBJ}\5${COLRESET}\t${COLTAGS}\6${COLRESET}\t\1/" \
| column -s "$(printf '\t')" -t -l 3 -R 1,2
}
# List all tags of matching entries. If not query is provided, all tags are
# listed.
# @argument $1: query (optional)
list_tags() {
[ "${1:-}" ] && query="$1" || query="tag:/./"
$NOTMUCH search --output=tags "$query"
}
# List all email addresses
list_addresses() {
$NOTMUCH address '*'
}
# List query history
list_query_history() {
cat "$NMFHIST"
}

41
src/sh/notmuch.sh Normal file
View File

@@ -0,0 +1,41 @@
# Wrapper around notmuch
# Print the message id of the last message within a thread.
# @argument $1: thread id
nm_last_message_in_thread() {
# TODO: We may be smarter here that just incorporating excluded messages
$NOTMUCH search --output=messages --offset=-1 --exclude=false thread:"$1" | sed 's/^...//'
}
# Print the header of a message (with trailing empty line)
# @argument $1: message id
nm_message_header() {
$NOTMUCH show --body=false id:"$1" | awk "$AWK_MESSAGEHEADER"
}
# Print the message parts (with indents)
# @argument $1: message id
nm_message_parts() {
$NOTMUCH show --body=true id:"$1" | awk "$AWK_MESSAGEPARTS"
}
# Print the message part number for text/plain or text/html
# @argument $1: message id
# @argument $2: if set, then the html part number will be printed
nm_message_part_nr() {
$NOTMUCH show --body=true id:"$1" | awk -v html="${2:-}" "$AWK_PARTNR"
}
# Print part of message
# @argument $1: message id
# @argument $2: part number
nm_message_get_part() {
$NOTMUCH show --part="$2" id:"$1"
}
# Add/remove a tag
# @argument $1: [+/-]tag
# @argument $2: query
nm_tag() {
$NOTMUCH tag "$1" "$2"
}

26
src/sh/preview.sh Normal file
View File

@@ -0,0 +1,26 @@
# Preview functions
# Preview email
# If a thread identifier is given, then the last message in the thread is
# shown. If the HTML flag is set, then the HTML message is parsed using pandoc.
# This functions reverts to the HTML method if no HTML flag is set yet no
# text/plain part is found.
#
# @argument $1: "id" or "thread"
# @argument $2: message id or thread id
# @argument #3: if set, then the HTML messages will be taken
preview_message() {
[ "$1" = "id" ] && messageid="$2" || messageid="$(nm_last_message_in_thread "$2")"
echo "preview_message: messageid=$messageid" >> /tmp/foo
parts="$(nm_message_parts "$messageid")"
echo "preview_message: parts=$parts" >> /tmp/foo
html="${3:-}"
echo "preview_message: html=$html" >> /tmp/foo
nr="$(nm_message_part_nr "$messageid" "$html")"
echo "preview_message: nr=$nr" >> /tmp/foo
[ ! "$nr" ] && [ ! "$html" ] && html="html" && nr="$(nm_message_part_nr "$messageid" "html")"
echo "preview_message: nr=$nr" >> /tmp/foo
[ "$html" ] && parser="$PANDOC" || parser="cat"
nm_message_header "$messageid" | $CATEMAIL
[ "$nr" ] && (nm_message_get_part "$messageid" "$nr" | $parser | $CATMD)
}

View File

@@ -1,12 +1,18 @@
# Default theme
if [ ! "${THEME_LOADED:-}" ]; then
COLDATE="$(printf '\033[38;5;195m')"
COLCNTS="$(printf '\033[38;5;244m')"
COLFROM="$(printf '\033[38;5;208m')"
COLSUBJ="$(printf '\033[38;5;179m\033[3m')"
COLTAGS="$(printf '\033[38;5;106m\033[2m')"
ANSICOLORDATE="${ANSICOLORDATE:-195}"
ANSICOLORCNTS="${ANSICOLORCNTS:-244}"
ANSICOLORFROM="${ANSICOLORFROM:-208}"
ANSICOLORSUBJ="${ANSICOLORSUBJ:-179}"
ANSICOLORTAGS="${ANSICOLORTAGS:-106}"
COLDATE="$(printf '\033[38;5;%sm' "$ANSICOLORDATE")"
COLCNTS="$(printf '\033[38;5;%sm' "$ANSICOLORCNTS")"
COLFROM="$(printf '\033[38;5;%sm' "$ANSICOLORFROM")"
COLSUBJ="$(printf '\033[38;5;%sm\033[3m' "$ANSICOLORSUBJ")"
COLTAGS="$(printf '\033[38;5;%sm\033[2m' "$ANSICOLORTAGS")"
COLRESET="$(printf '\033[0m')"
export ANSICOLORDATE ANSICOLORCNTS ANSICOLORFROM ANSICOLORSUBJ ANSICOLORTAGS
export COLDATE COLCNTS COLFROM COLSUBJ COLTAGS COLRESET
export THEME_LOADED=1

View File

@@ -1,6 +1,6 @@
if [ ! "${TOOLS_LOADED:-}" ]; then
if command -v "fzf" >/dev/null; then
FZF="fzf --black --ansi --cycle --tiebreak=chunk,index"
FZF="fzf --black --ansi --cycle --info=inline-right"
else
err "Did not find the command-line fuzzy finder fzf."
exit 1
@@ -20,9 +20,17 @@ if [ ! "${TOOLS_LOADED:-}" ]; then
elif command -v "batcat" >/dev/null; then
CAT="batcat"
fi
CAT=${CAT:+$CAT -l email --style=plain --color=always --wrap}
CAT=${CAT:-cat}
export CAT
CATEMAIL=${CAT:+$CAT -l email --style=plain --color=always}
CATMD=${CAT:+$CAT -l markdown --style=plain --color=always}
CATEMAIL=${CATEMAIL:-cat}
CATEMD=${CATMD:-cat}
export CATEMAIL CATMD
if command -v "pandoc" >/dev/null; then
PANDOC="pandoc --from html --to markdown_strict-raw_html"
fi
PANDOC=${PANDOC:-cat}
export PANDOC
export TOOLS_LOADED=1
fi