From 14003a8016ef6572a85541010e8e0b955d4bc9cd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 4 May 2022 08:35:52 +0200 Subject: ... --- accounts/gkleen@sif/zshrc | 80 +++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'accounts/gkleen@sif/zshrc') diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index bcdc662a..712ec690 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -111,7 +111,7 @@ dir() { forceShell=false wormhole=false gitWorktree="" - notmuchMsg="" + # notmuchMsg="" quickserve=false while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do @@ -132,7 +132,7 @@ dir() { "r") repoUrl=${OPTARG} ;; "w") wormhole=true ;; "g") gitWorktree=${OPTARG} ;; - "n") notmuchMsg=${OPTARG} ;; + # "n") notmuchMsg=${OPTARG} ;; "q") quickserve=true ;; *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; esac @@ -189,56 +189,56 @@ dir() { fi - if [[ -n ${notmuchMsg} ]]; then - getMimeTypes() { - nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat" - } + # if [[ -n ${notmuchMsg} ]]; then + # getMimeTypes() { + # nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat" + # } - typeset -a messages - messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})}) + # typeset -a messages + # messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})}) - for message (${messages}); do - typeset -A notmuchAtts - notmuchAtts=() + # for message (${messages}); do + # typeset -A notmuchAtts + # notmuchAtts=() - while IFS= read -r -d $'\n' line; do - [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue - attId=${match[2]} + # while IFS= read -r -d $'\n' line; do + # [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue + # attId=${match[2]} - [[ ${line} =~ 'Content-type: multipart/' ]] && continue + # [[ ${line} =~ 'Content-type: multipart/' ]] && continue - fName="part_${attId}" - [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]} + # fName="part_${attId}" + # [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]} - if [[ ${#messages} -gt 1 ]]; then - fName="${message}/${fName}" - fi + # if [[ ${#messages} -gt 1 ]]; then + # fName="${message}/${fName}" + # fi - fExt="${fName:e}" - [[ -n "${fExt}" ]] && fName="${fName:r}" + # fExt="${fName:e}" + # [[ -n "${fExt}" ]] && fName="${fName:r}" - if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then - fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }') - fi + # if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then + # fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }') + # fi - mkdir -p ${fName:h} - if [[ -n "${fExt}" ]]; then - fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}") - else - fName=$(mktemp -p . "${fName}.XXXXXX") - fi + # mkdir -p ${fName:h} + # if [[ -n "${fExt}" ]]; then + # fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}") + # else + # fName=$(mktemp -p . "${fName}.XXXXXX") + # fi - notmuchAtts[${attId}]=${fName} - done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f') + # notmuchAtts[${attId}]=${fName} + # done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f') - for attId fName in ${(kv)notmuchAtts}; do - [[ -d ${fName:h} ]] || mkdir -p ${fName:h} - printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2 + # for attId fName in ${(kv)notmuchAtts}; do + # [[ -d ${fName:h} ]] || mkdir -p ${fName:h} + # printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2 - notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName} - done - done - fi + # notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName} + # done + # done + # fi ${wormhole} && wormhole receive -- cgit v1.2.3