X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/1f3e9c63f48d77bb709d6db73d5e0f9df559bec6..7cc6ed072e7c6b3128e121609e0279d95760363c:/.mutt/container-extractor?ds=inline diff --git a/.mutt/container-extractor b/.mutt/container-extractor new file mode 100755 index 0000000..e8dec52 --- /dev/null +++ b/.mutt/container-extractor @@ -0,0 +1,46 @@ +#!/bin/sh +set -eu + +SELF="${0##*/}" + +if [ -z "${TMPDIR:-}" ]; then + TMPDIR=/tmp +fi +for i in $LOGNAME volatile; do + if [ -d "${TMPDIR}/$i" ]; then + TMPDIR="${TMPDIR}/$i" + break + fi +done +export TMPDIR +TMPDIR=$(mktemp -dp "$TMPDIR" cont.XXXXXXXXXX) +cleanup() +{ + cd / && rm -r "$TMPDIR" + [ ! -t 0 ] || stty echo + trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +} +trap cleanup 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 + +cd "$TMPDIR" + +case "$1" in + (application/ms-tnef) tnef;; + (application/x-zip-compressed) unzip /dev/stdin;; + (application/zip) unzip /dev/stdin;; +esac + +nfiles=$(ls -1 | wc -l) +if [ $nfiles -eq 1 ]; then + + set -x + setsid run-mailcap * & + PID=$! + ZSH_PREFILL_CMD="mv '$(echo -n *)' " x-terminal-emulator + perl -e "kill '-TERM', $PID" + +else + + ZSH_RUN_ON_LOAD="ls -l" x-terminal-emulator + +fi