dotfiles/files/mutt/.local/bin/mutt-sorcerer
Ben Grande c1987240bc
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.
2024-01-26 22:43:46 +01:00

36 lines
916 B
Bash
Executable File

#!/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}"