refactor: muttrc configuration source order

Script to source muttrc configuration is preferred as it can choose what
files must exist and not throw extraneous error messages on optional
files. Adding the example configuration files to slim out the readme
from the qusal project, also helps with copying the file from inside
the qube itself instead of having to copy inter-qube.
This commit is contained in:
Ben Grande 2024-01-26 22:43:46 +01:00
parent dcf2909f53
commit c1987240bc
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
13 changed files with 97 additions and 16 deletions

View File

@ -7,6 +7,10 @@ Files: files/git/.config/git/message
Copyright: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: MIT
Files: files/mutt/.config/mutt/sample/*.example
Copyright: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: GPL-3.0-or-later
Files: files/sh/.config/less/lesskey-old
Copyright: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: GPL-3.0-or-later

View File

@ -23,6 +23,9 @@ set charset = "utf-8"
set pager_index_lines = 5
set my_editor = "vim -c 'setf mail' "
set editor = "$my_editor "
set mailcap_path = "~/.mailcap"
unauto_view *
auto_view text/plain text/html
## Composing
## Option 'use_envelope_from' does not work reliably, force Message-ID
@ -46,6 +49,10 @@ set forward_format = "Fwd: %s"
set forward_quote
## Cache
set spoolfile = "+INBOX"
## GMail duplicates sent mails if the 'record' option is set.
#set record = "+Sent"
unset record
set mbox = "~/.cache/mutt/archived"
set record = "~/.cache/mutt/sent"
set postponed = "~/.cache/mutt/postponed"

View File

@ -4,7 +4,6 @@
## IMAP
set folder = "imaps://imap.$my_server"
set spoolfile = "+INBOX"
set imap_user = "$my_user"
set imap_pass = "$my_pass"
set imap_check_subscribed
@ -20,9 +19,6 @@ set pop_last = yes
## SMTP
set smtp_url = "smtps://$my_user@smtp.$my_server"
## GMail duplicates sent mails if the 'record' option is set.
#set record = "+Sent"
unset record
set smtp_pass = "$my_pass"
set realname = "$my_name"
set ssl_starttls = yes

View File

@ -8,10 +8,9 @@
## Hooks
send-hook "~A" "set pgp_autoinline=no"
send-hook "~t ^security@qubes-os\\.org$" "set pgp_autoinline=yes crypt_autoencrypt=yes"
send-hook "~t @invisiblethingslab\\.com" "set pgp_autoinline=yes crypt_autoencrypt=yes"
send-hook "~t ^security@qubes-os\\.org$" "set pgp_autoinline=no crypt_autoencrypt=yes"
send-hook "~t @invisiblethingslab\\.com" "set pgp_autoinline=no crypt_autoencrypt=yes"
send-hook "~t @googlegroups\\.com" "set pgp_autoinline=yes crypt_autoencrypt=no"
send-hook "~t $from" "set pgp_autoinline=yes"
## General Encryption and Signature
set crypt_autopgp = yes # Use PGP for encryption

View File

@ -2,14 +2,7 @@
##
## SPDX-License-Identifier: AGPL-3.0-or-later
## Source configuration
## Source all configurations
cd ~/.config/mutt
source ~/.muttrc-credentials.local
source server.muttrc
source mailbox.muttrc
source pgp.muttrc
source bindings.muttrc
source colors.muttrc
source ~/.muttrc-aliases.local
source ~/.muttrc.local
source mutt-sorcerer|
## vim: ft=muttrc

View File

@ -0,0 +1,4 @@
## Copy to ~/.muttrc-aliases.local and modify.
## Optional configuration.
alias qubes-devel <qubes-devel@googlegroups.com>

View File

@ -0,0 +1,12 @@
## Copy to ~/.muttrc-credentials.local and modify.
## Mandatory configuration.
## First file to be sourced: defines variables to be referenced by other files.
set pgp_default_key = "0x1234567890ABCDEF"
set pgp_sign_as = "0x1234567890ABCDEF"
set my_name = "Bilbo Baggins"
set my_user = "bilbo"
set my_server = "shire.org"
## Password is unnecessary if Mutt is permanently offline.
set my_pass = "mypassword"

View File

@ -0,0 +1,8 @@
## Copy to ~/.muttrc.local and modify.
## Optional configuration.
## Last file to be source: overrides previous definitions.
lists .*@googlegroups\\.com
subscribe qubes-(announce|devel)@googlegroups\\.com
fcc-save-hook qubes-announce@googlegroups\\.com =list/qubes-announce/
fcc-save-hook qubes-devel@googlegroups\\.com =list/qubes-devel/

View File

@ -0,0 +1,19 @@
## Copy to ~/.config/mutt/offline.muttrc and modify.
## SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
set read_only = yes
unset spoolfile
unset folder
unset smtp_url
set imap_passive = yes
set sendmail = "env EMAIL_CONN_TEST=x /usr/libexec/msmtp/msmtpq/msmtpq"
set sendmail_wait = 0
set folder = "~/mail"
set spoolfile = "+INBOX"
## vim: ft=muttrc

View File

@ -0,0 +1,4 @@
## Copy to ~/.signature and modify, including deleting all commends.
## Optional configuration.
Regards,
John Doe

View File

@ -0,0 +1,35 @@
#!/bin/sh
##
## SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
##
## Mutt Sorcerer - source Mutt configuration like a wizard
## Useful if some configurations files in non-default locations might exist.
set -eu
credentials_file="${HOME}/.muttrc-credentials.local"
aliases_file="${HOME}/.muttrc-aliases.local"
local_file="${HOME}/.muttrc.local"
## source_redable(): do not require that the file exists in the first place.
source_existent(){
for file in "${@}"; do
if test -f "${file}"; then
echo source "\"${file}\""
fi
done
unset file
}
## Source files that must exist, let mutt fail otherwise.
echo source "\"${credentials_file}\""
## PWD is inherited from the muttrc that called this script.
for file in *.muttrc; do
echo source "\"${file}\""
done
unset file
source_existent "${aliases_file}" "${local_file}"