Skip to content

Instantly share code, notes, and snippets.

@amandabee amandabee/.offlineimaprc
Last active Jul 24, 2018

Embed
What would you like to do?
Mutt, Not Much, Offlinimap and Bash
[general]
accounts = Velociraptor
pythonfile = ~/.offlineimap/pass.py
[Account Velociraptor]
localrepository = VelLocal
remoterepository = VelRemote
# In 7.0 sqlite is the only thing supported
# status_backend = sqlite
postsynchook = notmuch new
[Repository VelRemote]
type = IMAP
remotehost = mail.{redacted}
cert_fingerprint = {redacted}
remoteuser = amanda@{redacted}
remotepasseval = get_pass("amanda")
ssl = yes
[Repository VelLocal]
type = Maildir
localfolders = ~/Maildir
restoreatime = no

No joke: Thunderbird has been getting super bloated lately. Searches take forever. So I've been easing my way into Notmuch and mutt which is actually great. I still need to work out an address book, but this works well for me.

To Do

  • DONE: Get my password out of cleartext (using pass now)
  • Respect non ASCII characters
  • DONE: for a while I was running notmuch new after offlineimap but I added postsynchook = notmuch new to my offlineimap config instead.

HTML Attachments

To reliably open HTML in a browser, you need to add a line to mailcap:

text/html; firefox %s;copiousoutput

And you need to set mailcap_path = ~/.mailcap in neomuttrc

While Loop

while true; do time offlineimap && date +"%T"; sleep 20m; done

Crontab

*/10 * * * * offlineimap -q -u quiet

text/html; firefox %s;copiousoutput
application/ics; khal import -a logistics %s
text/calendar; khal import -a logistics %s
source ~/.config/neomutt/pass.sh|
set smtp_url = "smtp://amanda@{redacted}@mail.{redacted}:587/"
set smtp_pass = $my_pass
set ssl_force_tls = yes
set from = "amanda@{redacted}"
set realname = "Amanda Hickman"
set signature = "~/.config/neomutt/signature"
set status_format = "%n new | %M in %f [%v]."
set xterm_set_titles = yes
# notmuch
set nm_default_uri="notmuch:///home/amanda/Mail" # path to the maildir
set spoolfile = ~/Mail/INBOX
set record = ~/Mail/INBOX.Sent
set postponed = ~/Mail/INBOX.Drafts
set mbox_type = Maildir
set folder = ~/Mail/
# notmuch bindings
bind index,pager \ noop
macro index,pager \\\\ "<vfolder-from-query>" # looks up a hand made query
macro index A "<modify-labels>+archive -unread -inbox\\n" # tag as Archived
macro index I "<modify-labels>-inbox -unread\\n" # removed from inbox
macro index S "<modify-labels-then-hide>-inbox -unread +junk\\n" # tag as Junk mail
macro index + "<modify-labels>+*\\n<sync-mailbox>" # tag as starred
macro index - "<modify-labels>-*\\n<sync-mailbox>" # tag as unstarred
# ctrl u searches for URLs
macro pager \cu |urlview\n
# Remap bounce-message function to “B”
bind index B bounce-message
# show the year via http://www.sendmail.org/~ca/email/mutt/manual-6.html#index_format
set index_format = "%4C %Z %{%b %d %Y} %-15.15L (%?l?%4l&%4c?) %s"
## Save Hooks
save-hook '~s [Rr]eceipt' =INBOX.receipts
save-hook '~s order\ confirmation' =INBOX.receipts
save-hook '~s authorized\ a\ payment' =INBOX.receipts
save-hook '~e Venmo' =INBOX.receipts
save-hook . =INBOX.Archives.2018
## Addressing
macro pager,index a "<pipe-message>khard add-email<return>" "add the sender address to khard"
set query_command= "khard email --parsable %s"
bind editor <Tab> complete-query
bind editor ^T complete
set mailcap_path = ~/.config/mailcap
set print_command="/home/amanda/.mutt/print.sh"
#! /usr/bin/env python2
from subprocess import check_output
def get_pass(account):
return check_output("pass Velociraptor/" + account, shell=True).splitlines()[0]
#! /bin/bash
# Script to extract my password via pass
my_pass=$(pass Velociraptor/amanda)
echo set my_pass = ${my_pass}
#!/bin/bash
input="$1" pdir="$HOME/Desktop" open_pdf=evince
# check to make sure that enscript and ps2pdf are both installed
if ! command -v enscript >/dev/null || ! command -v ps2pdf >/dev/null; then
echo "ERROR: both enscript and ps2pdf must be installed" 1>&2
exit 1
fi
# create temp dir if it does not exist
if [ ! -d "$pdir" ]; then
mkdir -p "$pdir" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Unable to make directory '$pdir'" 1>&2
exit 2
fi
fi
tmpfile="`mktemp $pdir/mutt_XXXXXXXX.pdf`"
enscript --font=Courier8 $input -2r --word-wrap --fancy-header=mutt --encoding=88593 -p - 2>/dev/null | ps2pdf - $tmpfile
$open_pdf $tmpfile >/dev/null 2>&1 &
sleep 1
rm $tmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.