Skip to content

Instantly share code, notes, and snippets.

@mricon
Last active December 14, 2023 19:23
Show Gist options
  • Save mricon/b1ef6e10cceb227352274e1b888409b0 to your computer and use it in GitHub Desktop.
Save mricon/b1ef6e10cceb227352274e1b888409b0 to your computer and use it in GitHub Desktop.
my-gen-msgid
#!/bin/bash
# This generates lore-friendly message-id headers that are safe, unique, and
# provide better UX for someone using lore to retrieve messages.
#
# Instructions for using with mutt/neomutt:
#
# Save this as ~/bin/my-gen-msgid, then add ~/.mutt-fix-msgid with the following,
# fixing your path to the file:
#
# my_hdr Message-ID: <`/home/user/bin/my-gen-msgid`>
#
# then edit ~/.muttrc to add:
#
# send-hook . "source ~/.mutt-fix-msgid"
#
# I like my msgid to start with the date
msgid="$(date +%Y%m%d)-"
if [[ -x /bin/diceware ]]; then
# I like memorable nonsense, so I can visually tell one message from another,
# by looking at the lore URL, so use diceware for that
msgid="${msgid}$(diceware --no-caps -d- -n2)-$(openssl rand -hex 6)"
else
# Just use openssl with some extra randomness
msgid="${msgid}$(openssl rand -hex 12)"
fi
# Don't leak my hostname, just use something that makes sense to me
echo -n "${msgid}@meerkat"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment