Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mutt mail config, mostly copied from @sjl
* Relies on Keychain access on OS X
* See: http://stevelosh.com/blog/2012/10/the-homely-mutt
  • Loading branch information
gf3 committed Mar 27, 2013
1 parent 702322d commit 2bd53e5
Show file tree
Hide file tree
Showing 16 changed files with 620 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .msmtprc
@@ -0,0 +1,11 @@
account runlevel6
host smtp.gmail.com
port 587
protocol smtp
auth on
from gianni@runlevel6.org
user gianni@runlevel6.org
tls on
tls_trust_file ~/.mutt/Equifax_Secure_CA.cert

account default : runlevel6
17 changes: 17 additions & 0 deletions .mutt/Equifax_Secure_CA.cert
@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQGEwJVUzEQMA4GA1UE
ChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5
MB4XDTk4MDgyMjE2NDE1MVoXDTE4MDgyMjE2NDE1MVowTjELMAkGA1UEBhMCVVMxEDAOBgNVBAoT
B0VxdWlmYXgxLTArBgNVBAsTJEVxdWlmYXggU2VjdXJlIENlcnRpZmljYXRlIEF1dGhvcml0eTCB
nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwV2xWGcIYu6gmi0fCG2RFGiYCh7+2gRvE4RiIcPR
fM6fBeC4AfBONOziipUEZKzxa1NfBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+AcJkVV5MW
8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kCAwEAAaOCAQkwggEFMHAG
A1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQMA4GA1UEChMHRXF1aWZheDEtMCsGA1UE
CxMkRXF1aWZheCBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoG
A1UdEAQTMBGBDzIwMTgwODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvS
spXXR9gjIBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQFMAMB
Af8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUAA4GBAFjOKer89961
zgK5F7WF0bnj4JXMJTENAKaSbn+2kmOeUJXRmm/kEd5jhW6Y7qj/WsjTVbJmcVfewCHrPSqnI0kB
BIZCe/zuf6IWUrVnZ9NA2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee95
70+sB3c4
-----END CERTIFICATE-----
Empty file added .mutt/alias
Empty file.
44 changes: 44 additions & 0 deletions .mutt/badwolf.muttrc
@@ -0,0 +1,44 @@
color normal color15 color233
color error brightcolor15 color196
color indicator color15 color235
color status brightcolor39 color233
color markers color142 color233

color hdrdefault color245 color233
color header brightcolor214 color233 "^(Subject): "
color signature color243 color233

color body color137 color233 [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+
color body color137 color233 ((https?|ftp)://|www)+[\-\.\;@,/%~_:?&=\#a-zA-Z0-9+]+
color bold brightcolor15 color233
color search brightcolor16 color221

color quoted color243 color233
color quoted1 color211 color233
color quoted2 color222 color233
color quoted3 color214 color233
color quoted4 color154 color233

color tilde color240 color233
color tree color240 color233
color attachment brightcolor211 color233

# http://www.mutt.org/doc/manual/manual-4.html#ss4.2
# color index color241 color233 ~A
# color index color241 color233 ~Q
# color index color243 color233 ~P
color index color221 color233 ~N
color index brightcolor211 color233 ~F
color index brightcolor39 color233 ~T
color index color243 color233 ~Q
color index color196 color233 ~D

# Colorize inline diffs, really helpful for LKML or other mailing lists where
# mails frequently include patches.
color body brightcolor15 color233 '^diff .*'
color body brightcolor15 color233 '^[Ii]{1}ndex .*'
color body brightcolor15 color233 '^=+$'
color body brightcolor15 color233 '^(---|\+\+\+) .*'
color body brightcolor15 color233 '^@@ .*'
color body color121 color233 '^\+([^\+].*)?$'
color body color211 color233 '^-([^-].*)?$'
Empty file added .mutt/cache/bodies/.gitkeep
Empty file.
Empty file added .mutt/cache/headers/.gitkeep
Empty file.
35 changes: 35 additions & 0 deletions .mutt/mailcap
@@ -0,0 +1,35 @@
# ~/.mutt/mailcap
#
# this uses the view_attachment script found in ~/.mutt/view_attachment.sh
#
# this is meant for an OS X system

# MS Excel
# this will use the default xls spreadsheet handler from open
application/x-msexcel; ~/.mutt/view_attachment.sh %s
application/ms-exc; ~/.mutt/view_attachment.sh %s
application/excel; ~/.mutt/view_attachment.sh %s
application/msexcel; ~/.mutt/view_attachment.sh %s
application/vnd.ms-exc; ~/.mutt/view_attachment.sh %s
application/vnd.ms-excel; ~/.mutt/view_attachment.sh %s

# MS Word
# use textedit to open .doc files as it's more light-weight
application/msword; ~/.mutt/view_attachment.sh %s "-" '/Applications/TextEdit.app'

# Images
image/jpg; ~/.mutt/view_attachment.sh %s jpg
image/jpeg; ~/.mutt/view_attachment.sh %s jpg
image/pjpeg; ~/.mutt/view_attachment.sh %s jpg
image/png; ~/.mutt/view_attachment.sh %s png
image/gif; ~/.mutt/view_attachment.sh %s gif

# PDF
# application/pdf; ~/.mutt/view_attachment.sh %s pdf

# HTML
text/html; ~/.mutt/view_attachment.sh %s html

# Unidentified.
application/octet-stream; ~/.mutt/view_attachment.sh %s "-"

222 changes: 222 additions & 0 deletions .mutt/muttrc
@@ -0,0 +1,222 @@
# Paths {{{

set alias_file = ~/.mutt/alias # where to store aliases
set header_cache = ~/.mutt/cache/headers # where to store headers
set message_cachedir = ~/.mutt/cache/bodies # where to store bodies
set certificate_file = ~/.mutt/certificates # where to store certs
set mailcap_path = ~/.mutt/mailcap # entries for filetypes
set tmpdir = ~/.mutt/temp # where to keep temp files
set signature = ~/.mutt/sig # my signature file

# }}}
# Editor {{{

# Use Vim to compose email, with a few default options.
set editor = "/usr/local/bin/vim -c 'normal! }' -c 'redraw'"

# }}}
# Contacts {{{

# Use the OS X address book
set query_command = "contacts -Sf '%eTOKEN%n' '%s' | sed -e 's/TOKEN/\t/g'"
bind editor <Tab> complete-query
bind editor ^T complete

# }}}
# Basic Options {{{

source ~/.mutt/badwolf.muttrc

set wait_key = no # shut up, mutt
set mbox_type = Maildir # mailbox type
set folder = ~/.mail # mailbox location
set timeout = 3 # idle time before scanning
set mail_check = 0 # minimum time between scans
unset move # gmail does that
set delete # don't ask, just do
unset confirmappend # don't ask, just do!
set quit # don't ask, just do!!
unset mark_old # read/new is good enough for me
set beep_new # bell on new mails
set pipe_decode # strip headers and eval mimes when piping
set thorough_search # strip headers and eval mimes before searching

# }}}
# Sidebar Patch {{{

set sidebar_delim = ' │'
set sidebar_visible = yes
set sidebar_width = 24
color sidebar_new color221 color233
bind index,pager <down> sidebar-next
bind index,pager <up> sidebar-prev
bind index,pager <right> sidebar-open

# }}}
# Status Bar {{{

set status_chars = " *%A"
set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"

# }}}
# Index View Options {{{

set date_format = "%m/%d"
set index_format = "[%Z] %D %-20.20F %s"
set sort = threads # like gmail
set sort_aux = reverse-last-date-received # like gmail
set uncollapse_jump # don't collapse on an unread message
set sort_re # thread based on regex
set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"

# }}}
# Pager View Options {{{

set pager_index_lines = 10 # number of index lines to show
set pager_context = 3 # number of context lines to show
set pager_stop # don't go to next message automatically
set menu_scroll # scroll in menus
set tilde # show tildes like in vim
unset markers # no ugly plus signs
set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
alternative_order text/plain text/enriched text/html

# }}}
# Compose View Options {{{

set realname = "Gianni Chiappetta" # who am i?
set envelope_from # which from?
set sig_dashes # dashes before sig
set edit_headers # show headers when composing
set fast_reply # skip to compose when replying
set askcc # ask for CC:
set fcc_attach # save attachments with the body
unset mime_forward # forward attachments as part of body
set forward_format = "Fwd: %s" # format of subject when forwarding
set forward_decode # decode when forwarding
set attribution = "On %d, %n wrote:" # format of quoting header
set reply_to # reply to Reply to: field
set reverse_name # reply as whomever it was to
set include # include message in replies
set forward_quote # include message in forwards

# }}}
# Headers {{{

ignore * # ignore all headers
unignore from: to: cc: date: subject: # show only these
unhdr_order *
hdr_order from: to: cc: date: subject: # and in this order

# }}}
# steve@stevelosh.com {{{

# Default inbox.
set spoolfile = "+gianni-runlevel6.org/INBOX"

# Alternate email addresses.
alternates gianni@metalabdesign.com

# Mailboxes to show in the sidebar.
mailboxes +gianni-runlevel6.org/INBOX \
+gianni-runlevel6.org/vim \
+gianni-runlevel6.org/clojure \
+gianni-runlevel6.org/python \
+gianni-runlevel6.org/mercurial \
+gianni-runlevel6.org/archive \
+gianni-runlevel6.org/sent \
+gianni-runlevel6.org/drafts \
+temporary/search \

# Other special folders.
set mbox = "+gianni-runlevel6.org/archive"
set postponed = "+gianni-runlevel6.org/drafts"

# Sending email.
set from = "gianni@runlevel6.org"
set sendmail = "/usr/local/bin/msmtp -a gianni"
set sendmail_wait = 0 # no please don't silently fail, email is important
unset record

# }}}
# Account Hooks {{{

# folder-hook gianni-runlevel6.org/* source ~/.mutt/gianni-runlevel6.org.muttrc

# }}}
# Key Bindings {{{

# Index {{{

bind index \# noop
bind index R group-reply
bind index <tab> sync-mailbox
bind index k previous-entry
bind index j next-entry
bind index gg first-entry
bind index G last-entry
bind index p recall-message
bind index <space> collapse-thread
bind index N search-opposite
macro index s "<pipe-message>cat > ~/Desktop/" "save message as"

# Mark all as read
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"

# Sync email
macro index O "<shell-escape>offlineimap<enter>" "run offlineimap to sync all mail"
macro index o "<shell-escape>offlineimap -qf INBOX<enter>" "run offlineimap to sync inbox"

# Saner copy/move dialogs
macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"

# Quickly change mailboxes
macro index \' "<change-folder>+gianni-runlevel6.org/INBOX<enter>" "go to INBOX"
macro index \" "<change-folder>+gianni-runlevel6.org/archive<enter>" "go to archive"

# Search with notmuch
macro index S "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py -G ~/.mail/temporary/search<enter><change-folder-readonly>+temporary/search<enter>" "search mail (using notmuch)"

# Unlimit (show [a]ll)
macro index a "<limit>all\n" "show all messages (undo limit)"

# }}}
# Pager {{{

bind pager \# noop
bind pager k previous-line
bind pager j next-line
bind pager gg top
bind pager G bottom

bind pager R group-reply
bind pager N search-opposite

macro pager \Cu "|urlview<enter>" "call urlview to open links"
macro pager s "<pipe-message>cat > ~/Desktop/" "save message as"

# Quickly change mailboxes
macro pager \' "<exit><change-folder>+gianni-runlevel6.org/INBOX<enter>" "go to INBOX"
macro pager \" "<exit><change-folder>+gianni-runlevel6.org/archive<enter>" "go to archive"

# }}}
# Compose {{{

bind compose p postpone-message

# }}}
# Attachment {{{

# View, god dammit!
bind attach <return> view-mailcap

# }}}
# "Open in Vim" {{{

macro index,pager V "|vim -c 'setlocal ft=mail' -c 'setlocal buftype=nofile' -<enter>" "open in vim"
macro index,pager M "|mvim -c 'setlocal ft=mail' -c 'setlocal buftype=nofile' - >/dev/null<enter>" "open in macvim"

# }}}

# }}}
16 changes: 16 additions & 0 deletions .mutt/offlineimap.py
@@ -0,0 +1,16 @@
#!/usr/bin/python
import re, subprocess
def get_keychain_pass(account=None, server=None):
params = {
'security': '/usr/bin/security',
'command': 'find-internet-password',
'account': account,
'server': server,
'keychain': '/Users/`whoami`/Library/Keychains/login.keychain',
}
command = "sudo -u `whoami` %(security)s -v %(command)s -g -a %(account)s -s %(server)s %(keychain)s" % params
output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
outtext = [l for l in output.splitlines()
if l.startswith('password: ')][0]

return re.match(r'password: "(.*)"', outtext).group(1)
18 changes: 18 additions & 0 deletions .mutt/offlineimapsync.sh
@@ -0,0 +1,18 @@
#!/bin/sh

PID=`cat ~/.offlineimap/pid`
ps aux | grep "[ ]$PID" && kill $PID

function sync_normal {
echo "NORMAL Sync"
/usr/local/share/python/offlineimap -o -u quiet
}
function sync_quick {
echo "QUICK Sync"
/usr/local/share/python/offlineimap -o -q -u quiet
}

# This is silly.
python -c'import sys, random; sys.exit(random.randint(0, 5))' && sync_normal || sync_quick

exit 0
3 changes: 3 additions & 0 deletions .mutt/sig
@@ -0,0 +1,3 @@
Gianni Chiappetta
Runlevel6
gf3.ca
Empty file added .mutt/temp/.gitkeep
Empty file.

0 comments on commit 2bd53e5

Please sign in to comment.