From dd58224a7e8f087634e0e8628f9789dc8201fbf4 Mon Sep 17 00:00:00 2001
From: Sergey Matveev <stargrave@stargrave.org>
Date: Mon, 31 Oct 2022 18:21:08 +0300
Subject: [PATCH] Newer mu and combined back/sent folders

---
 mutt/.mutt/muttrc       | 7 ++++---
 mutt/bin/sent           | 9 +++++++++
 zsh/.zsh/rc/010mail.zsh | 2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100755 mutt/bin/sent

diff --git a/mutt/.mutt/muttrc b/mutt/.mutt/muttrc
index 9b53c6d..b7fc957 100644
--- a/mutt/.mutt/muttrc
+++ b/mutt/.mutt/muttrc
@@ -2,7 +2,7 @@ set folder = "~/mail"
 set mbox_type = maildir
 # set mbox_type = mbox
 set spoolfile = =mbox
-set record = =sent-`date "+%y-%m"`
+set record = =back-`date "+%y-%m"`
 set postponed = =postponed
 set certificate_file = ~/.mutt/certificates
 set net_inc = 1
@@ -40,8 +40,9 @@ macro index,pager,browser <F1> "<next-unread-mailbox><enter>"
 macro index <F5> ":set mbox_type = mbox\n" "mbox mailbox type"
 macro index S "<save-message>=spamdb<enter>"
 
-macro index <F8> "<shell-escape>mu find --clearlinks --format=links --linksdir=~/mail/search " "mu find"
-macro index <F9> "<change-folder-readonly>~/mail/search<enter>" "mu find results"
+macro index <F6> "<shell-escape>mu find --clearlinks --format=links --linksdir=~/mail/search " "mu find"
+macro index <F7> "<change-folder-readonly>~/mail/search<enter>" "mu find results"
+macro index <F8> "<change-folder-readonly>~/mail/search-sent<enter>" "mu find sent results"
 
 macro pager \cu |urlview\n
 
diff --git a/mutt/bin/sent b/mutt/bin/sent
new file mode 100755
index 0000000..218097e
--- /dev/null
+++ b/mutt/bin/sent
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+alts=$(perl -lane '
+    next unless /^alternates/;
+    push @alts, "f:$F[1]";
+    sub END { print join " or ", @alts };
+' ~/.mutt/accounts/*)
+mfind date:2m.. "($alts)"
+mutt -f =search-sent
diff --git a/zsh/.zsh/rc/010mail.zsh b/zsh/.zsh/rc/010mail.zsh
index 8c5d995..50f8984 100644
--- a/zsh/.zsh/rc/010mail.zsh
+++ b/zsh/.zsh/rc/010mail.zsh
@@ -3,5 +3,5 @@ mailpath=(
     ~/mail/arbeit/new"?Neue Nachrichten in =arbeit"
 )
 alias arr="mutt -f =arbeit -e 'source ~/.mutt/accounts/arbeit'"
-alias sent="mutt -f =sent-\`date '+%y-%m'\`"
+export MUHOME=~/.mu
 bindkey -s "OP" " inc\n" # F1
-- 
2.51.0