summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/zshrc
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/zshrc')
-rw-r--r--accounts/gkleen@sif/zshrc80
1 files changed, 40 insertions, 40 deletions
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() {
111 forceShell=false 111 forceShell=false
112 wormhole=false 112 wormhole=false
113 gitWorktree="" 113 gitWorktree=""
114 notmuchMsg="" 114 # notmuchMsg=""
115 quickserve=false 115 quickserve=false
116 116
117 while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do 117 while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do
@@ -132,7 +132,7 @@ dir() {
132 "r") repoUrl=${OPTARG} ;; 132 "r") repoUrl=${OPTARG} ;;
133 "w") wormhole=true ;; 133 "w") wormhole=true ;;
134 "g") gitWorktree=${OPTARG} ;; 134 "g") gitWorktree=${OPTARG} ;;
135 "n") notmuchMsg=${OPTARG} ;; 135 # "n") notmuchMsg=${OPTARG} ;;
136 "q") quickserve=true ;; 136 "q") quickserve=true ;;
137 *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; 137 *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;;
138 esac 138 esac
@@ -189,56 +189,56 @@ dir() {
189 fi 189 fi
190 190
191 191
192 if [[ -n ${notmuchMsg} ]]; then 192 # if [[ -n ${notmuchMsg} ]]; then
193 getMimeTypes() { 193 # getMimeTypes() {
194 nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat" 194 # nix-shell -p mailcap --run "find \${buildInputs} -path '*/etc/mime.types' | head -n 1 | xargs -- cat"
195 } 195 # }
196 196
197 typeset -a messages 197 # typeset -a messages
198 messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})}) 198 # messages=(${(z)$(notmuch search --output=messages ${notmuchMsg})})
199 199
200 for message (${messages}); do 200 # for message (${messages}); do
201 typeset -A notmuchAtts 201 # typeset -A notmuchAtts
202 notmuchAtts=() 202 # notmuchAtts=()
203 203
204 while IFS= read -r -d $'\n' line; do 204 # while IFS= read -r -d $'\n' line; do
205 [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue 205 # [[ ${line} =~ '(attachment|part)\{ ID: ([0-9]+)' ]] || continue
206 attId=${match[2]} 206 # attId=${match[2]}
207 207
208 [[ ${line} =~ 'Content-type: multipart/' ]] && continue 208 # [[ ${line} =~ 'Content-type: multipart/' ]] && continue
209 209
210 fName="part_${attId}" 210 # fName="part_${attId}"
211 [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]} 211 # [[ ${line} =~ 'Filename: (([^,]|,[^ ])+)' ]] && fName=${match[1]}
212 212
213 if [[ ${#messages} -gt 1 ]]; then 213 # if [[ ${#messages} -gt 1 ]]; then
214 fName="${message}/${fName}" 214 # fName="${message}/${fName}"
215 fi 215 # fi
216 216
217 fExt="${fName:e}" 217 # fExt="${fName:e}"
218 [[ -n "${fExt}" ]] && fName="${fName:r}" 218 # [[ -n "${fExt}" ]] && fName="${fName:r}"
219 219
220 if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then 220 # if [[ -z "${fExt}" && ${line} =~ 'Content-type: (([^,]|,[^ ])+)$' ]]; then
221 fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }') 221 # fExt=$(getMimeTypes | grep ${match[1]}$'\t' | head -n 1 | awk '{ print $2; }')
222 fi 222 # fi
223 223
224 mkdir -p ${fName:h} 224 # mkdir -p ${fName:h}
225 if [[ -n "${fExt}" ]]; then 225 # if [[ -n "${fExt}" ]]; then
226 fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}") 226 # fName=$(mktemp -p . "${fName}.XXXXXX.${fExt}")
227 else 227 # else
228 fName=$(mktemp -p . "${fName}.XXXXXX") 228 # fName=$(mktemp -p . "${fName}.XXXXXX")
229 fi 229 # fi
230 230
231 notmuchAtts[${attId}]=${fName} 231 # notmuchAtts[${attId}]=${fName}
232 done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f') 232 # done <<(notmuch show --decrypt=false -- ${message} | tr -d $'\f')
233 233
234 for attId fName in ${(kv)notmuchAtts}; do 234 # for attId fName in ${(kv)notmuchAtts}; do
235 [[ -d ${fName:h} ]] || mkdir -p ${fName:h} 235 # [[ -d ${fName:h} ]] || mkdir -p ${fName:h}
236 printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2 236 # printf "#%d → ‘%s’\n" "${attId}" "${fName}" >&2
237 237
238 notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName} 238 # notmuch show --decrypt=false --part=${attId} -- ${message} | pv -W -D 2 -i 0.1 >${fName}
239 done 239 # done
240 done 240 # done
241 fi 241 # fi
242 242
243 243
244 ${wormhole} && wormhole receive 244 ${wormhole} && wormhole receive