On 13Sep2022 16:50, Sébastien Hinderer <sebastien.hinde...@ens-lyon.org> wrote:
I would like to have a nice way to deal with several accounts in mutt. I am talking just about the .muttrc file aspect here.

My present configuration is that each account has its own muttrc file
which sources a common one.

I thought the common approach was what you next outline: a single muttrc which sources the appropriate account-specific muttrc.

My own muttrc starts like this:

    source ~/private/rc/mutt/personal
    source ~/rc/mutt/settings
    source ~/rc/mutt/settings-forwarding
    ##source ~/rc/mutt/spam        # spam scoring settings
    source ~/rc/mutt/gpg
    source ~/rc/mutt/aliases-auto
    source ~/rc/mutt/lists

    mailboxes +me +sh +mutt +python

    auto_view text/html
    mime_lookup application/octet-stream

    mbox-hook +feeds +SAVED/feeds

    source ~/rc/mutt/macros

and then has a bunch of arbitrary stuff I haven't subcategorised. The "private/rc/mutt/personal" file has stuff like this:

    set my_cs='c...@cskk.id.au'
    set my_CS='Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au)'
    set my_cs_gmail='cameron.simp...@gmail.com'
    set my_CS_gmail="Cameron Simpson <$my_cs_gmail>"

    set my_local_mail="$HOME/mail"

    # email addresses in active use
    alternates '^cs@(zip.com.au|zipworld.com.au|cskk.id.au)$' \
               '^cameron@(cskk.id.au|.....)$' \
               ... etc etc ...

    set my_account_email=UNKNOWN

    # default
    reply-hook . "my_hdr BCC: $my_cs"
    reply-hook . 'set from="$NAME <$EMAIL>"'
    reply-hook '~C @googlegroups.com' 'set from="$my_CS_gmail"'

    folder-hook . 'set my_account_email=$my_cs; set folder=$my_local_mail'
# ... other patterns based on the folder path, usually for imap as # various identities ...
    folder-hook 'imaps://' 'set folder=imaps://$imap_user@$my_imap_host/'
    folder-hook . 'set status_format="$my_account_email %s/%S %P %l Msgs:%?M?%M/?%m%?n? 
New:%n?%?o? Del:%d?%?F? Flag:%F?%?t? Tag:%t?  f-%>-"'

    account-hook 'imaps://cs@mail\.zip\.com\.au/' 'source "cs-mutt-imap-settings 
zipworld |"'
    ...

I really need to revisit account-hook, but the approach here is to autoset account specific things with folder-hooks and reply-hooks. You could source your account specific rc files on that basis or via macros, etc.

Cheers,
Cameron Simpson <c...@cskk.id.au>

Reply via email to