~whynothugo/dotfiles

bb32a0933cc3c27a20096af5fda4573a5c4f91bf — Hugo Osvaldo Barrera a month ago 2a19d76
himitsu-mutt: Add support for reading username
1 files changed, 18 insertions(+), 3 deletions(-)

M home/.local/bin/himitsu-mutt
M home/.local/bin/himitsu-mutt => home/.local/bin/himitsu-mutt +18 -3
@@ 1,13 1,20 @@
#!/bin/sh
#
# A helper for neomutt to read password from himitsu only when required.
# A helper for neomutt to read password from himitsu only when required. This
# is designed to be used together with `account_command`, and will read the
# password only when required (e.g.: the SMTP password will be read only when
# sending an email). Himitu's agent will show an interactive prompt to confirm
# disclosing the password to neomutt.
#
# Add this to your neomutt config:
# Neomutt's configuration should contain something like:
#
#     set smtp_url = "smtps://my-username@smtp.example.com"
#     set account_command = "himitsu-mutt"
#
# A prompt for the smtp password will be shown only when sending emails.
# Defining the username is mutt's configuration is optional; if one is not
# defined, then it will be read from himitsu as well.
#
# See: https://git.labrat.space/neomutt/commit/?h=upstream/heads/main&id=89ddbf7036cf8ec43c6923238ee26a9844cf86ac

set -eu



@@ 35,5 42,13 @@ while [ $# -gt 0 ]; do
  esac
done

# If no username was provided, get that from himitsu as well.
# The username is not expected to be secret.
if [ -z "${USERNAME+x}" ]; then
  USERNAME=$(hiq -1F user "proto=$PROTO" "host=$HOSTNAME")
  echo "username: $USERNAME"
fi

# Extract and print the password.
PASSWORD=$(hiq -dF password "proto=$PROTO" "host=$HOSTNAME" "user=$USERNAME")
echo "password: $PASSWORD"