Mutt: Support message caching with purging

master
Pierre Neidhardt 2015-10-08 22:54:42 +02:00
parent 5ecc4e52f6
commit eedbc32156
3 changed files with 22 additions and 1 deletions

19
.mutt/cachepurge.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
## Purge old message in Mutt's message cache.
## This is intended to be run at startup, but can be run manually anytime.
## It should not output anything to stdout.
## In KB.
CACHE_LIMIT=51200
cd ~/.cache/mutt_msg 2>/dev/null
[ $? -ne 0 ] && exit
[ $(du -s . | cut -f1 -d' ') -lt $CACHE_LIMIT ] && exit
while IFS= read -r i; do
rm "$i"
[ $(du -s . | cut -f1 -d' ') -lt $CACHE_LIMIT ] && exit
done <<EOF
$(ls -rt $(find . -type f))
EOF

View File

@ -30,6 +30,8 @@ source "~/.mutt/maileditor.sh|"
## folder is specified, it is even faster. If no folder exists, the cache will
## be a single file.
set header_cache = "~/.cache/mutt"
set message_cachedir = "~/.cache/mutt_msg"
source "~/.mutt/cachepurge.sh|"
## Tell Mutt to check all IMAP folders. This will add all of them to the
## sidebar. Contrary to the manu 'mailboxes' way, order cannot be controlled, so

View File

@ -20,7 +20,7 @@ fi
if command -v mutt >/dev/null 2>&1; then
echo "==> Mutt"
[ -d "$SOURCEDIR" ] && ln -snf "$SOURCEDIR/mails" "$HOME/.mutt.d"
mkdir -p "$HOME/.cache/mutt/hcache"
mkdir -p "$HOME/.cache/mutt/"
echo
fi