dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit 7f14bad7f073c04d98dac013c9f58cbd4c21db6b
parent 3fbc1fbc4f8757e2a9b883187223eb30d971e078
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri,  1 May 2020 16:03:49 -0700

mutt: import mutt, mbsync, msmtp, notmuch config

Imports config for mutt and supporting programs from the previously
separate mutt repo.

Diffstat:
A.config/mutt/aliases | 0
A.config/mutt/colors | 43+++++++++++++++++++++++++++++++++++++++++++
A.config/mutt/crypto | 42++++++++++++++++++++++++++++++++++++++++++
A.config/mutt/mailcap | 15+++++++++++++++
A.config/mutt/mutt-notmuch-py | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.mbsyncrc | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.msmtprc | 16++++++++++++++++
A.muttrc | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.notmuch-config | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.urlview | 1+
MMakefile | 13+++++++++++++
11 files changed, 537 insertions(+), 0 deletions(-)

diff --git a/.config/mutt/aliases b/.config/mutt/aliases diff --git a/.config/mutt/colors b/.config/mutt/colors @@ -0,0 +1,43 @@ +# Colors ---------------------------------------------- +# general-doesn't-fit stuff +color normal color252 color233 +color error color193 color124 +color markers color142 color233 +color tilde color142 color233 +color status color172 color233 + +# index stuff +color tree color244 color233 +color indicator color255 color235 +color index color117 color233 ~N +color index color124 color233 ~D + +# header stuff +color hdrdefault color248 color233 +color header color226 color233 "^Subject" + +# url, email and web stuff +color body color68 color233 "(finger|ftp|http|https|news|telnet)://[^ >]*" +color body color111 color233 "<URL:[^ ]*>" +color body color111 color233 "www\\.[-.a-z0-9]+\\.[a-z][a-z][a-z]?([-_./~a-z0-9]+)?" +color body color111 color233 "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+" +color body brightred color233 "^-.*" +color body green color233 "^[+].*" +color body brightwhite color233 "^diff .*" +color body brightyellow color233 "^@@.*" + +# misc body stuff +color attachment color111 color233 +color signature color244 color233 + +# quote levels +color quoted color34 color233 +color quoted1 color142 color233 +color quoted2 color34 color233 +color quoted3 color142 color233 +color quoted4 color34 color233 +color quoted5 color142 color233 +color quoted6 color34 color233 +color quoted7 color142 color233 +color quoted8 color34 color233 +color quoted9 color142 color233 diff --git a/.config/mutt/crypto b/.config/mutt/crypto @@ -0,0 +1,42 @@ +set pgp_use_gpg_agent=yes +set pgp_decode_command="gpg --no-verbose --batch --output - %f" +set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f" +set pgp_decrypt_command="gpg --no-verbose --batch --output - %f" +set pgp_sign_command="gpg --no-verbose --batch --output - --armor --detach-sign --textmode %?a?-u %a? %f" +set pgp_clearsign_command="gpg --no-verbose --batch --output - --armor --textmode --clearsign %?a?-u %a? %f" +set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xCBE8A8FE -- -r %r -- %f" +set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xCBE8A8FE -- -r %r -- %f" +set pgp_import_command="gpg --no-verbose --import -v %f" +set pgp_export_command="gpg --no-verbose --export --armor %r" +set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r" +set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r" +set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r" + +# specify the uid to use when encrypting/signing +set pgp_sign_as=0xCBE8A8FE + +# this set the number of seconds to keep in memory the passpharse used to encrypt/sign +# the more the less secure it will be +set pgp_timeout=60 + +# it's a regexp used against the GPG output: if it matches some line of the output +# then mutt considers the message a good signed one (ignoring the GPG exit code) +set pgp_good_sign="^gpg: Good signature from" + +# mutt uses by default PGP/GPG to sign/encrypt messages +# if you want to use S-mime instead set the smime_is_default variable to yes + +# automatically sign all outgoing messages +unset crypt_autosign +# sign only replies to signed messages +set crypt_replysign + +# automatically encrypt outgoing messages +unset crypt_autoencrypt +# encrypt only replies to signed messages +set crypt_replyencrypt=yes +# encrypt and sign replies to encrypted messages +set crypt_replysignencrypted=yes + +# automatically verify the sign of a message when opened +set crypt_verify_sig=yes diff --git a/.config/mutt/mailcap b/.config/mutt/mailcap @@ -0,0 +1,15 @@ +# Images +image/jpg; eog %s +image/jpeg; eog %s +image/pjpeg; eog %s +image/png; eog %s +image/gif; eog %s + +# PDFs +application/pdf; evince %s + +# HTML +text/html; w3m -I %{charset} -dump %s; nametemplate=%s.html; copiousoutput + +# GPG +application/pgp-encrypted; gpg --decrypt; copiousoutput diff --git a/.config/mutt/mutt-notmuch-py b/.config/mutt/mutt-notmuch-py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +""" +mutt-notmuch-py + +This is a Gmail-only version of the original mutt-notmuch script. + +It will interactively ask you for a search query and then symlink the matching +messages to $HOME/.cache/mutt_results. + +Add this to your muttrc. + +macro index / "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py<enter><change-folder-readonly>~/.cache/mutt_results<enter>" \ + "search mail (using notmuch)" + +This script overrides the $HOME/.cache/mutt_results each time you run a query. + +Install this by adding this file somewhere on your PATH. + +Only tested on OSX Lion. + +(c) 2012 - Honza Pokorny +Licensed under BSD +""" +import hashlib, subprocess, sys +from mailbox import Maildir +from optparse import OptionParser + + +def digest(filename): + with open(filename, 'rb') as f: + return hashlib.sha1(f.read()).hexdigest() + + +def pick_all_mail(messages): + for m in messages: + if 'All Mail' in m: + return m + + +def empty_dir(directory): + box = Maildir(directory) + box.clear() + + +def command(cmd): + return subprocess.check_output(cmd, shell=True) + + +def main(dest_box): + query = input('Query: ') + + command('mkdir -p %s' % dest_box) + command('mkdir -p %s/cur' % dest_box) + command('mkdir -p %s/new' % dest_box) + + empty_dir(dest_box) + + output = command('notmuch search --output=files %s' % query) + files = output.decode('utf-8').split('\n') + files = filter(None, files) + + data = {} + messages = [] + + for f in files: + sha = digest(f) + if sha not in data.keys(): + data[sha] = [f] + else: + data[sha].append(f) + + for sha in data.keys(): + if is_gmail and len(data[sha]) > 1: + messages.append(pick_all_mail(data[sha])) + else: + messages.append(data[sha][0]) + + for m in messages: + command('ln -s "%s" %s/cur/' % (m, dest_box)) + + +if __name__ == '__main__': + global is_gmail + + p = OptionParser("usage: %prog [OPTIONS] [RESULTDIR]") + p.add_option('-g', '--gmail', dest='gmail', + action='store_true', default=True, + help='gmail-specific behavior') + p.add_option('-G', '--not-gmail', dest='gmail', + action='store_false', + help='gmail-specific behavior') + (options, args) = p.parse_args() + + is_gmail = options.gmail + + if args: + dest = args[0] + else: + dest = '~/.cache/mutt_results' + + main(dest.rstrip('/')) diff --git a/.mbsyncrc b/.mbsyncrc @@ -0,0 +1,91 @@ +# mbsync config + +# NOTES: +# * Use PipelineDepth to throttle so we don't go over GMail's query quota. +# See: https://sourceforge.net/p/isync/mailman/message/35458365/ +# +# * If account is configured with Japanese as primary, use the following: +# +# 下書き '[Gmail]/&Tgtm+DBN-' '[Gmail]/Drafts' +# 送信済みメール '[Gmail]/&kAFP4W4IMH8w4TD8MOs-' '[Gmail]/Sent Mail' +# スター付き '[Gmail]/&MLkwvzD8TtgwTQ-' '[Gmail]/Starred' +# ゴミ箱 '[Gmail]/&MLQw33ux-' '[Gmail]/Bin' +# すべてのメール '[Gmail]/&MFkweTBmMG4w4TD8MOs-' '[Gmail]/All Mail' +# 迷惑メール '[Gmail]/&j,dg0TDhMPww6w-' '[Gmail]/Spam' +# 重要 '[Gmail]/&kc2JgQ-' '[Gmail]/Important' + +###################################################################### +# chris@bracken.jp + +IMAPAccount bracken_jp +Host imap.gmail.com +Port 993 +User chris@bracken.jp +PassCmd "gpg -q --batch -d ~/src/cfg/keyring/mbsync.bracken_jp.gpg" +AuthMechs LOGIN +SSLType IMAPS +PipelineDepth 50 +#CertificateFile ~/.homebrew/etc/openssl/cert.pem +#CertificateFile /etc/ssl/certs/ca-certificates.crt +CertificateFile /usr/local/share/certs/ca-root-nss.crt + +# Create bracken.jp remote +IMAPStore bracken_jp-remote +Account bracken_jp + +# Create bracken.jp local +MaildirStore bracken_jp-local +Path ~/Mail/chris-bracken.jp/ +Inbox ~/Mail/chris-bracken.jp/INBOX +Flatten "." + +Channel bracken_jp-default +Master :bracken_jp-remote: +Slave :bracken_jp-local: +Patterns "INBOX" +Create Slave +Expunge Both +SyncState * + +Channel bracken_jp-drafts +Master :bracken_jp-remote:"[Gmail]/Drafts" +Slave :bracken_jp-local:"drafts" +Create Slave +Expunge Both +SyncState * + +Channel bracken_jp-sent +Master :bracken_jp-remote:"[Gmail]/Sent Mail" +Slave :bracken_jp-local:"sent" +Create Slave +Expunge Both +SyncState * + +Channel bracken_jp-starred +Master :bracken_jp-remote:"[Gmail]/Starred" +Slave :bracken_jp-local:"flagged" +Create Slave +Expunge Both +SyncState * + +Channel bracken_jp-trash +Master :bracken_jp-remote:"[Gmail]/Bin" +Slave :bracken_jp-local:"trash" +Create Slave +Expunge Both +SyncState * + +Channel bracken_jp-archive +Master :bracken_jp-remote:"[Gmail]/All Mail" +Slave :bracken_jp-local:"archive" +Create Slave +Expunge Both +SyncState * + +Group bracken_jp +Channel bracken_jp-default +Channel bracken_jp-drafts +Channel bracken_jp-sent +Channel bracken_jp-starred +Channel bracken_jp-trash +Channel bracken_jp-archive diff --git a/.msmtprc b/.msmtprc @@ -0,0 +1,16 @@ +defaults +auth on +tls on +#tls_trust_file /etc/ssl/certs/ca-certificates.crt +#tls_trust_file ~/.homebrew/etc/openssl/cert.pem +tls_trust_file /usr/local/share/certs/ca-root-nss.crt + +# Gmail +account bracken_jp +host smtp.gmail.com +port 587 +from chris@bracken.jp +user chris@bracken.jp +passwordeval gpg --batch -d ~/src/cfg/keyring/msmtp.bracken_jp.gpg + +account default : bracken_jp diff --git a/.muttrc b/.muttrc @@ -0,0 +1,146 @@ +# Paths ---------------------------------------------- +set folder = ~/Mail # mailbox location +set alias_file = ~/.config/mutt/aliases # where to store aliases +set header_cache = ~/.cache/mutt/headers # where to store headers +set message_cachedir = ~/.cache/mutt/bodies # where to store bodies +set tmpdir = ~/.cache/mutt/tmp # where to keep temp files +set certificate_file = ~/.config/mutt/certificates # where to store certs +set mailcap_path = ~/.config/mutt/mailcap # entries for filetypes +set signature = ~/.config/mutt/sig # my signature file + +# Aliases -------------------------------------------- +set sort_alias = alias +set reverse_alias = yes +source $alias_file + +# Account Settings ----------------------------------- +# Default inbox. +set spoolfile = "+chris-bracken.jp/INBOX" + +# Alternate email addresses. +alternates chris@bracken.jp + +# Mailboxes to show in the sidebar. +mailboxes +chris-bracken.jp/INBOX \ + +chris-bracken.jp/archive \ + +chris-bracken.jp/sent \ + +chris-bracken.jp/drafts + +# Other special folders. +set mbox = "+chris-bracken.jp/archive" +set postponed = "+chris-bracken.jp/drafts" +set record = "+chris-bracken.jp/sent" + +# Basic Options -------------------------------------- +set wait_key = no # don't prompt for <enter> so much +set mbox_type = Maildir # mailbox type +set timeout = 3 # idle time before scanning +set mail_check = 0 # minimum time between scans +set copy = no # don't store a copy of sent mail in the record +set delete # don't confirm deletes +unset move # gmail does that +unset confirmappend # don't prompt every time we append to mailbox +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 +set markers = no + +# Use abook instead of aliases +set query_command = "abook --mutt-query '%s'" +macro generic,index,pager \ca "<shell-escape>abook<return>" "launch abook" +macro index,pager A "<pipe-message>abook --add-email<return>" "add sender to address book" +bind editor <tab> complete-query + +# Index View Options --------------------------------- +set date_format = "!%Y-%m-%d %H:%M %Z" +set index_format = "%Z %D %-20.20F (%4c) %s" +set sort = threads +set sort_aux = reverse-last-date-received +set uncollapse_jump +set sort_re +set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*" +bind index P recall-message + +# Index Key Bindings --------------------------------- +bind index gg first-entry +bind index G last-entry +bind index H help +bind index R group-reply +bind index ? search-opposite +bind index <space> collapse-thread +macro index a "<limit>all\n" "show all messages (undo limit)" +macro index o "<shell-escape>mbsync bracken_jp; notmuch new<enter>" "sync core mailboxes" +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" +macro index gi "<change-folder>=chris-bracken.jp/INBOX<enter>" "Go to Inbox" +macro index ga "<change-folder>=chris-bracken.jp/archive<enter>" "Go to All Mail" +macro index gs "<change-folder>=chris-bracken.jp/sent<enter>" "Go to Sent Mail" +macro index gd "<change-folder>=chris-bracken.jp/drafts<enter>" "Go to Drafts" +macro index S "<enter-command>unset wait_key<enter><shell-escape>~/.mutt/mutt-notmuch-py -G ~/mail/.tmp/search<enter><change-folder-readonly>+.tmp/search<enter>" "search mail (using notmuch)" + +# 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]+[>|]+)+" +auto_view text/html application/pgp-encrypted +alternative_order text/plain text/enriched text/html + +# Pager Key Bindings --------------------------------- +bind pager gg top +bind pager G bottom +bind pager H help +bind pager j next-entry +bind pager k previous-entry +bind pager \Cj next-line +bind pager \Ck previous-line +bind pager u half-up +bind pager <space> half-down +bind pager R group-reply +bind pager ? search-opposite +bind attach <return> view-mailcap # View attachments properly. +macro pager \Cu "|urlview<enter>" "call urlview to open links" + +# Header Options ------------------------------------- +ignore * # ignore all headers +unignore date: from: to: cc: subject: # show only these +unhdr_order * # some distros order things by default +hdr_order date: from: to: cc: subject: # and in this order + +# Compose View Options ------------------------------- +set realname = "Chris Bracken" +set use_from = yes +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 = "%d %n <%a>:" # reply quote 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 + +# Editor ---------------------------------------------- +set editor='vim + -c "set nocp" -c "set textwidth=72" -c "set wrap" -c "silent /^$" -c "noh" -c "vmap <leader>s c[... snip ...]<ESC>" + +# Send Options --------------------------------------- +set from = "chris@bracken.jp" +set sendmail = "msmtp -a bracken_jp" +set sendmail_wait = 0 + +# 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 )?───" + +source ~/.config/mutt/colors +source ~/.config/mutt/crypto diff --git a/.notmuch-config b/.notmuch-config @@ -0,0 +1,69 @@ +# .notmuch-config - Configuration file for the notmuch mail system +# +# For more information about notmuch, see http://notmuchmail.org + +# Database configuration +# +# The only value supported here is 'path' which should be the top-level +# directory where your mail currently exists and to where mail will be +# delivered in the future. Files should be individual email messages. +# Notmuch will store its database within a sub-directory of the path +# configured here named ".notmuch". +# +[database] +path=Mail + +# User configuration +# +# Here is where you can let notmuch know how you would like to be +# addressed. Valid settings are +# +# name Your full name. +# primary_email Your primary email address. +# other_email A list (separated by ';') of other email addresses +# at which you receive email. +# +# Notmuch will use the various email addresses configured here when +# formatting replies. It will avoid including your own addresses in the +# recipient list of replies, and will set the From address based on the +# address to which the original email was addressed. +# +[user] +name=Chris Bracken +primary_email=chris@bracken.jp +other_email=chris.bracken@gmail.com; + +# Configuration for "notmuch new" +# +# The following options are supported here: +# +# tags A list (separated by ';') of the tags that will be +# added to all messages incorporated by "notmuch new". +# +[new] +tags=unread;inbox +ignore=.tmp;.mbsyncstate;.uidvalidity + +# Maildir compatibility configuration +# +# The following option is supported here: +# +# synchronize_flags Valid values are true and false. +# +# If true, then the following maildir flags (in message filenames) +# will be synchronized with the corresponding notmuch tags: +# +# Flag Tag +# ---- ------- +# D draft +# F flagged +# P passed +# R replied +# S unread (added when 'S' flag is not present) +# +# The "notmuch new" command will notice flag changes in filenames +# and update tags, while the "notmuch tag" and "notmuch restore" +# commands will notice tag changes and update flags in filenames +# +[maildir] +synchronize_flags=true diff --git a/.urlview b/.urlview @@ -0,0 +1 @@ +COMMAND xdg-open %s diff --git a/Makefile b/Makefile @@ -28,6 +28,19 @@ install-x: ln -s "$(REPO_DIR)/.Xdefaults" ~/ ln -s "$(REPO_DIR)/.Xmodmap" ~/ +install-mutt: + ln -s $(REPO_DIR)/.mbsyncrc ~/ + ln -s $(REPO_DIR)/.msmtprc ~/ + ln -s $(REPO_DIR)/.muttrc ~/ + ln -s $(REPO_DIR)/.notmuch-config ~/ + ln -s $(REPO_DIR)/.urlview ~/ + chmod 600 ~/.msmtprc + mkdir -p ~/.config + ln -s $(REPO_DIR)/.config/mutt ~/.config/mutt + mkdir -p ~/.cache/mutt/headers + mkdir -p ~/.cache/mutt/bodies + mkdir -p ~/.cache/mutt/tmp + install-fontconf: ln -s "$(REPO_DIR)/.fonts.conf" ~/ fc-cache -f -v