#!/bin/bash set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR offlineimap -u quiet shopt -s nullglob omv() { # offlineimap mv. move mail files within $src_base/$1 to /m/md/$2 src="$1" dst="$2" found_files=false for x in new cur; do files=("$src_base"/"$src"/$x/*) if [[ $files ]]; then found_files=true mv "${files[@]}" /m/md/"$dst"/$x fi done } src_base=/m/offlineimap omv "Sent Items" "Sent" omv INBOX offlineimaptmp src_base=/m/md if $found_files; then sieve-filter -eW ~/sieve/main.sieve offlineimaptmp &>/dev/null # the default folder is INBOX for anything leftover omv offlineimaptmp INBOX # remove messages from remote host offlineimap -u quiet # this makes us sit and wait when we want to use mu and this is running in a cronjob. # todo: emacs updates the index much faster. what command is it running? I'd like # to just run that # looks like it might be mu index --lazy-check, but that still takes like 10 seconds, # figure out if that is the same speed, or if we can make it faster. #mu index &>/dev/null ||: fi