diff options
author | Aaron LI <aaronly.me@gmail.com> | 2016-01-06 22:59:26 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@gmail.com> | 2016-01-06 22:59:26 +0800 |
commit | 25b947edf445a96db335fe285a8b253b214649ff (patch) | |
tree | 3f785cdbef303c71111debd067c95a62ea456587 /_mutt | |
parent | 0ed3373f1c2d47aba769aa67439e05350c2792e9 (diff) | |
download | dotfiles-25b947edf445a96db335fe285a8b253b214649ff.tar.bz2 |
Rename .* => _*; Move out private contents.
Diffstat (limited to '_mutt')
-rw-r--r-- | _mutt/attachments | 64 | ||||
-rw-r--r-- | _mutt/colors | 129 | ||||
-rw-r--r-- | _mutt/compose.rc | 15 | ||||
-rwxr-xr-x | _mutt/compose.sh | 14 | ||||
-rwxr-xr-x | _mutt/excel2text.sh | 31 | ||||
-rw-r--r-- | _mutt/gpg.rc | 108 | ||||
-rw-r--r-- | _mutt/mailcap | 119 | ||||
-rwxr-xr-x | _mutt/mutt-notmuch.py | 120 | ||||
-rwxr-xr-x | _mutt/mutt-xlabel.py | 164 | ||||
-rwxr-xr-x | _mutt/mutt_bgrun.sh | 118 | ||||
-rwxr-xr-x | _mutt/mutt_octet_view.sh | 278 | ||||
-rw-r--r-- | _mutt/muttrc | 251 | ||||
-rwxr-xr-x | _mutt/ppt2text.sh | 23 | ||||
-rwxr-xr-x | _mutt/word2text.sh | 67 |
14 files changed, 1501 insertions, 0 deletions
diff --git a/_mutt/attachments b/_mutt/attachments new file mode 100644 index 0000000..74575de --- /dev/null +++ b/_mutt/attachments @@ -0,0 +1,64 @@ +## +## Mutt attchment searching and counting configuration +## +## Weitian Li +## 2012/02/08 +## +## Ref: file:///usr/local/share/doc/mutt/html/mimesupport.html +## + +# Removing a pattern from a list removes that pattern literally. It +# does not remove any type matching the pattern. +# +# attachments +A */.* +# attachments +A image/jpeg +# unattachments +A */.* +# +# This leaves "attached" image/jpeg files on the allowed attachments +# list. It does not remove all items, as you might expect, because the +# second */.* is not a matching expression at this time. +# +# Remember: "unattachments" only undoes what "attachments" has done! +# It does not trigger any matching on actual messages. + +# Qualify any MIME part with an "attachment" disposition, EXCEPT for +# text/x-vcard and application/pgp parts. (PGP parts are already known +# to mutt, and can be searched for with ~g, ~G, and ~k.) +# +# I've added x-pkcs7 to this, since it functions (for S/MIME) +# analogously to PGP signature attachments. S/MIME isn't supported +# in a stock mutt build, but we can still treat it specially here. +# + +attachments +A */.* +attachments -A text/x-vcard application/pgp.* +attachments -A application/x-pkcs7-.* + + +# Discount all MIME parts with an "inline" disposition, unless they're +# text/plain. (Why inline a text/plain part unless it's external to the +# message flow?) + +attachments +I text/plain + + +# These two lines make Mutt qualify MIME containers. (So, for example, +# a message/rfc822 forward will count as an attachment.) The first +# line is unnecessary if you already have "attach-allow */.*", of +# course. These are off by default! The MIME elements contained +# within a message/* or multipart/* are still examined, even if the +# containers themselves don't qualify. + +#attachments +A message/.* multipart/.* +#attachments +I message/.* multipart/.* + + +## You probably don't really care to know about deleted attachments. +attachments -A message/external-body +attachments -I message/external-body + +## Then entering the command “attachments ?” as a command will list +## your current settings in Muttrc format, so that it can be pasted +## elsewhere. + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=muttrc: # diff --git a/_mutt/colors b/_mutt/colors new file mode 100644 index 0000000..de2f902 --- /dev/null +++ b/_mutt/colors @@ -0,0 +1,129 @@ +## +## Color settings for mutt. +## +## Weitian LI +## 2015/02/02 +## +## Ref: http://aperiodic.net/phil/configs/mutt/colors +## + +# Default color definitions +color normal white default +color hdrdefault green default +color quoted green default +color quoted1 yellow default +color quoted2 blue default +color signature cyan default +color indicator brightwhite blue +color error brightred default +color status brightblue black +color tree brightmagenta default +color tilde blue default +color attachment brightyellow default +color markers brightblue default +color message white default +color search brightwhite magenta +color bold brightyellow default + +# Color definitions when on a mono screen +mono bold bold +mono underline underline +mono indicator reverse +mono error bold + +# Colors for items in the header +color header brightmagenta default "^(From|Subject):" +color header brightyellow default "^Date:" +color header brightblue default "^To:" +color header brightcyan default "^Cc:" +color header brightblue default "^X-Label:" +mono header bold "^(From|Subject):" + + +# Many of these formulas were stolen from Jeremy Blosser +# These would be much simpler if colors were additive. + +# regular new messages +color index brightwhite default "~N !~T !~F !~p !~P" +# regular tagged messages +color index brightcyan default "~T !~F !~p !~P" +# regular flagged messages +color index brightblue default "~F !~p !~P" +# messages to me +color index yellow default "~p !~N !~T !~F !~P" +color index brightblue default "~p ~N !~T !~F !~P" +color index black cyan "~p ~T !~F !~P" +color index black magenta "~p ~F !~P" +# messages from me +color index green default "~P !~N !~T !~F" +color index brightblue default "~P ~N !~T !~F" +color index black cyan "~P ~T !~F" +color index black magenta "~P ~F" +# messages which mention my name in the body +#color index yellow default "~b \"([Ww]eitian|[Aa]ly|ly)\" !~N !~T !~F !~p !~P" +#color index brightyellow white "~b \"([Ww]eitian|[Aa]ly|ly)\" ~N !~T !~F !~p !~P" +#color index yellow cyan "~b \"([Ww]eitian|[Aa]ly|ly)\" ~T !~F !~p !~P" +#color index yellow red "~b \"([Ww]eitian|[Aa]ly|ly)\" ~F !~p !~P" +# messages which are in reference to my mails +#color index magenta default "~x \"(liweitianux|aaronly.me)@\" !~N !~T !~F !~p !~P" +#color index magenta white "~x \"(liweitianux|aaronly.me)@\" ~N !~T !~F !~p !~P" +#color index magenta cyan "~x \"(liweitianux|aaronly.me)@\" ~T !~F !~p !~P" +#color index magenta blue "~x \"(liweitianux|aaronly.me)@\" ~F !~p !~P" +# messages to root, etc. +color index cyan default "~C \"(root|postmaster|abuse|mailer-daemon)@\" !~N !~P !~p" +color index cyan white "~C \"(root|postmaster|abuse|mailer-daemon)@\" ~N !~P !~p" +# big messages +color index red default "!~N ~z 10485760-" +color index red cyan "~T !~F !~p !~P ~z 10485760-" +color index red white "~N ~z 10485760-" + +# deleted messages +color index brightred default "!~N ~D" +color index brightred white "~N ~D" + + +## Highlights inside the body of a message. + +# Attribution lines +color body magenta default "\\* [^<]+ <[^>]+> \\[[^]]+\\]:" +color body magenta default "(^|[^[:alnum:]])on [a-z0-9 ,]+( at [a-z0-9:,. +-]+)? wrote:" + +# URLs +color body brightyellow default "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]" + +# email addresses +color body brightmagenta default "((@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]),)*@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]):)?[0-9a-z_.+%$-]+@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\])" + +# PGP messages +color body brightblue default "^gpg: Good signature .*" +color body white default "^gpg: " +color body brightwhite red "^gpg: BAD signature from.*" +mono body bold "^gpg: Good signature" +mono body bold "^gpg: BAD signature from.*" + +# *bold* +color body brightblue default "(^|[[:space:][:punct:]])\\*[^*]+\\*([[:space:][:punct:]]|$)" +mono body bold "(^|[[:space:][:punct:]])\\*[^*]+\\*([[:space:][:punct:]]|$)" +# _underline_ +color body brightblue default "(^|[[:space:][:punct:]])_[^_]+_([[:space:][:punct:]]|$)" +mono body underline "(^|[[:space:][:punct:]])_[^_]+_([[:space:][:punct:]]|$)" +# /italic/ (sometimes gets directory names) +color body brightblue default "(^|[[:space:][:punct:]])/[^/]+/([[:space:][:punct:]]|$)" +mono body underline "(^|[[:space:][:punct:]])/[^/]+/([[:space:][:punct:]]|$)" + +# Various smilies and the like +color body brightwhite default "<[Gg]>" # <g> +color body brightwhite default "<[Bb][Gg]>" # <bg> +color body brightwhite default " [;:]-*[})>{(<|]" # :-) etc... + +# Border lines. +color body blue default "( *[-+=#*~_]){6,}" + +## Custom highlights +# arXiv number +color body brightyellow default "(^|[[:space:]])arXiv:[[:space:]0-9\.]+$" +# arXiv title +color body brightwhite default "(^|[[:space:]])Title:\ .+$" + + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=muttrc: # diff --git a/_mutt/compose.rc b/_mutt/compose.rc new file mode 100644 index 0000000..f2645d8 --- /dev/null +++ b/_mutt/compose.rc @@ -0,0 +1,15 @@ +# read main config +source ~/.mutt/muttrc + +# remove hooks, headers and sig, they are already in the draft +unhook send-hook +unset signature +unmy_hdr * + +set edit_headers # show headers when composing + +# call the right editor immediately +set autoedit +set editor = "vim +/^$/+1 -c 'set ft=mail enc=utf-8 tw=72'" + +# vim: set ts=8 sw=4 tw=0 fenc= ft=muttrc: # diff --git a/_mutt/compose.sh b/_mutt/compose.sh new file mode 100755 index 0000000..9172421 --- /dev/null +++ b/_mutt/compose.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Compose mail in new tmux/screen window. +# +# Reference: +# [1] Multi-window Mutt with Screen +# http://op-co.de/blog/posts/mulit-window_mutt/ +# + +# set the screen window title to the message receiver +#awk -F 'To: ' '/^To:/ { print "\033k" $2 "\033\\" }' "$1" + +mutt -F ~/.mutt/compose.rc -H "$1" +rm "$1" diff --git a/_mutt/excel2text.sh b/_mutt/excel2text.sh new file mode 100755 index 0000000..c3d0f14 --- /dev/null +++ b/_mutt/excel2text.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# excel2text - convert MS Excel files to ASCII text +# +# Written by Gary Johnson <garyjohn@spk.agilent.com>. +# +# Modification History: +# 2003-02-19 +# Changed the name xlHtml to xlhtml to match the xlhtml-0.5 +# release. + +prog=${0##*/} + +if [ $# -ne 1 ] +then + echo "Usage: $prog file" >&2 + exit 2 +fi + +xlhtml -te "$1" | +perl -pe 's/>-{21,}</><HR></g' | # This replaces long lines of + # hyphens with HTML <HR> tags so + # that these lines adapt to the + # width of the cell. "21" is a + # value that works for the + # tables I'm sent. +w3m -dump -T text/html | +perl -pe ' + s/\xa0/ /gs; # Change A0 spaces to ASCII + # spaces. +' diff --git a/_mutt/gpg.rc b/_mutt/gpg.rc new file mode 100644 index 0000000..e918768 --- /dev/null +++ b/_mutt/gpg.rc @@ -0,0 +1,108 @@ +## +## Mutt GPG configuration +## -*-muttrc-*- +## +## Weitian LI +## 2015/02/02 +## +## Reference: +## [1] A Quick Guide to Mutt #GPG +## http://srobb.net/mutt.html#GPG +## [2] Encrypting Mutt +## http://jasonwryan.com/blog/2013/07/20/gnupg/ +## + +# %p The empty string when no passphrase is needed, +# the string "PGPPASSFD=0" if one is needed. +# +# %f Most PGP commands operate on a single file or a file +# containing a message. %f expands to this file's name. +# +# %s When verifying signatures, there is another temporary file +# containing the detached signature. %s expands to this +# file's name. +# +# %a In "signing" contexts, this expands to the value of the +# configuration variable $pgp_sign_as. You probably need to +# use this within a conditional % sequence. +# +# %r In many contexts, mutt passes key IDs to pgp. %r expands to +# a list of key IDs. + +# Note that we explicitly set the comment armor header since GnuPG, +# when used in some localiaztion environments, generates 8bit data +# in that header, thereby breaking PGP/MIME. + +# Decode application/pgp +set pgp_decode_command="gpg2 --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f" + +# Verify a pgp/mime signature +set pgp_verify_command="gpg2 --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f" + +# Decrypt a pgp/mime attachment +set pgp_decrypt_command="gpg2 --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f" + +# Create a pgp/mime signed attachment +set pgp_sign_command="gpg2 --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --detach-sign --textmode %?a?-u %a? %f" + +# Create a application/pgp signed (old-style) message +set pgp_clearsign_command="gpg2 --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --textmode --clearsign %?a?-u %a? %f" + +# Create a pgp/mime encrypted attachment +set pgp_encrypt_only_command="pgpewrap gpg2 --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f" + +# Create a pgp/mime encrypted and signed attachment +set pgp_encrypt_sign_command="pgpewrap gpg2 %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f" + +# Import a key into the public key ring +set pgp_import_command="gpg2 --no-verbose --import %f" + +# Export a key from the public key ring +set pgp_export_command="gpg2 --no-verbose --export --armor %r" + +# Verify a key +set pgp_verify_key_command="gpg2 --verbose --batch --fingerprint --check-sigs %r" + +# Read in the public key ring +set pgp_list_pubring_command="gpg2 --no-verbose --batch --quiet --with-colons --list-keys %r" + +# Read in the secret key ring +set pgp_list_secring_command="gpg2 --no-verbose --batch --quiet --with-colons --list-secret-keys %r" + +# Fetch keys +# set pgp_getkeys_command="pkspxycwrap %r" + +# Use gpg-agent +set pgp_use_gpg_agent + +# 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=1800 + +# Pattern for good signature - may need to be adapted to locale! +# +# 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" +# set pgp_good_sign="^gpgv?: Good signature from " +# OK, here's a version which uses gnupg's message catalog: +# set pgp_good_sign="`gettext -d gnupg -s 'Good signature from "' | tr -d '"'`" +# This version uses --status-fd messages +# set pgp_good_sign="^\\[GNUPG:\\] GOODSIG" + +# Automatically sign all outcoming messages +set crypt_autosign +# Sign only replies to signed messages +#set crypt_replysign + +# Automatically encrypt outcoming messages +#set crypt_autoencrypt +# Encrypt only replies to signed messages +set crypt_replyencrypt +# encrypt and sign replies to encrypted messages +#set crypt_replysignencrypted + +# Automatically verify the sign of a message when opened +set crypt_verify_sig + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=muttrc: # diff --git a/_mutt/mailcap b/_mutt/mailcap new file mode 100644 index 0000000..0ec3d81 --- /dev/null +++ b/_mutt/mailcap @@ -0,0 +1,119 @@ +# +# mailcap - MIME configuration file +# +# Reference: +# [1] Gray Johnson's Mutt Page +# http://www.spocom.com/users/gjohnson/mutt/ +# +# Modified: 2015/02/02 +# + + +# From the attachment menu, if X is running, HTML attachments are sent +# to netscape for viewing; otherwise, they are sent to w3m. For +# in-line viewing, the HTML is converted to text. +# +# [Comment-out next line so that we can use w3m even within X.] +#text/html; mutt_netscape %s; test=RunningX +text/html; w3m -T text/html -I %{charset} -dump %s; \ + nametemplate=%s.html; copiousoutput + +# Add capability to edit attachments from the compose menu. +# +# Mutt can only edit attachments if they have a mailcap edit entry. +# (This would be a good thing to fix.) However, a mailcap entry +# apparently must include the display function--it can't be defaulted. +# The combination "cat; copiousoutput" comes close to the default in +# that in invokes the default pager on the output of cat. However, +# there is apparently no way to specify the default editor--a shell +# environment variable such as $VISUAL or $EDITOR is as close as we can +# get. +# +text/plain; ~/.mutt/mutt_bgrun.sh gvim -f %s; \ + test=sh -c 'test -n "${DISPLAY}"' +text/plain; vim %s +text/*; cat; copiousoutput; edit=$EDITOR %s + +message/rfc822; cat; copiousoutput; edit=$EDITOR %s + +# The following Microsoft application MIME attachments are viewed from +# the attachment menu using LibreOffice. +# +application/msword; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/msword; word2text %s; copiousoutput +application/vnd.msword; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/vnd.msword; word2text %s; copiousoutput +application/vnd.openxmlformats-officedocument.wordprocessingml.document; \ + ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +# +application/excel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/excel; excel2text %s; copiousoutput +application/msexcel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/msexcel; excel2text %s; copiousoutput +application/vnd.ms-excel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/vnd.ms-excel; excel2text %s; copiousoutput +application/x-excel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/x-excel; excel2text %s; copiousoutput +application/x-msexcel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/x-msexcel; excel2text %s; copiousoutput +application/ms-Excel; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/ms-Excel; excel2text %s; copiousoutput +# +application/vnd.ms-powerpoint; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/vnd.ms-powerpoint; ppt2text %s; copiousoutput +application/x-mspowerpoint; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/x-mspowerpoint; ppt2text %s; copiousoutput +application/ppt; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/ppt; ppt2text %s; copiousoutput + + +application/pdf; ~/.mutt/mutt_bgrun.sh evince %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/pdf; pdftotext %s -; copiousoutput + +application/postscript; ~/.mutt/mutt_bgrun.sh evince %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/postscript; ps2ascii %s; copiousoutput + +application/rtf; ~/.mutt/mutt_bgrun.sh libreoffice %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/rtf; rtf2text %s; copiousoutput + +#application/ms-tnef; tnef -w %s + +#application/octet-stream; mutt_octet_view -x %s; test=RunningX +#application/octet-stream; mutt_octet_view -v %s +#application/octet-stream; mutt_octet_view %s; copiousoutput + +image/*; ~/.mutt/mutt_bgrun.sh feh %s; \ + test=sh -c 'test -n "${DISPLAY}"' + +video/*; ~/.mutt/mutt_bgrun.sh vlc %s; \ + test=sh -c 'test -n "${DISPLAY}"' + +# Open scripts +application/x-shellscript; ~/.mutt/mutt_bgrun.sh gvim -f %s; \ + test=sh -c 'test -n "${DISPLAY}"' +application/x-shellscript; vim %s + +# Show archive conents. +# +application/x-compressed-tar; tar -tf %s; copiousoutput +application/x-bzip-compressed-tar; \ + bunzip2 -c %s | tar -tf -; copiousoutput +application/x-tar-gz; gunzip -c %s | tar -tf -; copiousoutput +application/x-7z-compressed; 7z l %s; copiousoutput + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=mailcap: # diff --git a/_mutt/mutt-notmuch.py b/_mutt/mutt-notmuch.py new file mode 100755 index 0000000..880b987 --- /dev/null +++ b/_mutt/mutt-notmuch.py @@ -0,0 +1,120 @@ +#!/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. + +Tested on OSX Lion and Arch Linux. + +(c) 2012 - Honza Pokorny +Licensed under BSD +""" + +""" +ChangeLogs: +2015/02/02: Weitian LI + * replaced 'commands.getoutput' with 'subprocess' + * replaced 'raw_input' with 'input' + * fixed digest() with an Unicode encoding bug + * updated to use python 3.x +""" + +import os +import hashlib +import subprocess + +from mailbox import Maildir +from optparse import OptionParser +from collections import defaultdict + + +def digest(filename): + # Require python 3.x + with open(filename) as f: + return hashlib.sha1(f.read().encode('utf-8')).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, is_gmail): + query = input('Query: ') + + command('test -d %s/cur || mkdir -p %s/cur' % (dest_box, dest_box)) + command('test -d %s/new || mkdir -p %s/new' % (dest_box, dest_box)) + + empty_dir(dest_box) + + output = command('notmuch search --output=files %s' % query) + files = output.decode(encoding='UTF-8').split('\n') + + data = defaultdict(list) + messages = [] + + for f in files: + if not f: + continue + + try: + sha = digest(f) + data[sha].append(f) + except IOError: + print('File %s does not exist' % f) + + for sha in data: + 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: + if not m: + continue + + target = os.path.join(dest_box, 'cur', os.path.basename(m)) + if not os.path.exists(target): + os.symlink(m, target) + + +if __name__ == '__main__': + 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() + + if args: + dest = args[0] + else: + dest = '~/.cache/mutt_results' + + # Use expanduser() so that os.symlink() won't get weirded out by tildes. + main(os.path.expanduser(dest).rstrip('/'), options.gmail) + diff --git a/_mutt/mutt-xlabel.py b/_mutt/mutt-xlabel.py new file mode 100755 index 0000000..ea96e37 --- /dev/null +++ b/_mutt/mutt-xlabel.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python3 +# +# Add/Modify 'X-Label' header for mutt. +# Label mails with mutt. +# +# Reference: +# [1] GTD (Getting Things Done) and Mutt +# https://docwhat.org/gtd-and-mutt/ +# +# muttrc settings: +# unignore X-Label: +# macro index,pager x '<enter-command>set my_oldeditor=$editor<enter><enter-command>set editor="~/.mutt/mutt-xlabel.py"<enter><edit><previous-undeleted><clear-flag>N<sync-mailbox><enter-command>set editor=$my_oldeditor<enter>' \ +# "edit X-Label" +# macro index \Cx "<limit>~y " \ +# "limit view to label" +# +# Weitian LI <liweitianux@gmail.com> +# 2015/02/06 +# + +import sys +import os +import email +import readline + + +# Settings +HISTFILE = os.path.join(os.environ["HOME"], ".mutt/xlabel_history") +LABELFILE = os.path.join(os.environ["HOME"], ".mutt/xlabels") + + +class MyCompleter(object): + """ + Comstom completer for readline. + + Reference: + [1] autocomplete - How to code autocompletion in python? + http://stackoverflow.com/a/7821956 + """ + def __init__(self, options): + self.options = sorted(options) + + def complete(self, text, state): + if state == 0: # on first trigger, build possible matches + if text: # cache matches (entries that start with entered text) + self.matches = [s for s in self.options + if s and s.startswith(text)] + else: # no text entered, all matches possible + self.matches = self.options[:] + + # return match indexed by state + try: + return self.matches[state] + except IndexError: + return None + + +def my_input(prompt, default=None, completer=None): + if default is not None: + def pre_input_hook(): + readline.insert_text(default) + readline.redisplay() + readline.set_pre_input_hook(pre_input_hook) + # completer + if completer: + readline.set_completer(completer) + readline.parse_and_bind('tab: complete') + return input(prompt) + + +def load_labels(labelfile): + """ + Load saved labels from given labelfile, + return a list of labels. + """ + try: + with open(labelfile, 'r') as f: + label_list = f.read().split() + label_list = list(set(label_list)) + except FileNotFoundError: + label_list = [] + return label_list + + +def update_labels(labelfile, label_list, new_label_list): + """ + Save labels for later autocompletion. + """ + labels = sorted(list(set(label_list).union(set(new_label_list)))) + with open(labelfile, 'w') as f: + f.write(' '.join(labels)) + + +def get_xlabel(message): + """ + Get 'X-Label:' values from given Message object. + """ + labels = message.get_all('X-Label') + if labels: + label_str = ' '.join(labels) + else: + label_str = '' + # remove duplicates and sort + label_list = sorted(list(set(label_str.split()))) + return label_list + + +def write_xlabel(message, old_label_list, new_label_list, outfile): + """ + Update 'X-Label' value of given Message object; + then write Message object to outfile. + """ + # remove duplicates and sort + new_label_list = sorted(list(set(new_label_list))) + if set(old_label_list) != set(new_label_list): + # delete original 'X-Label' header (all occurences) + del message['X-Label'] + # add new 'X-Label' header + message['X-Label'] = ' '.join(new_label_list) + # write to outfile (Just OVERWRITE, OK??) + fp_out = open(outfile, 'w') + fp_out.write(message.as_string()) + fp_out.close() + + +def main(): + if len(sys.argv) != 2 and len(sys.argv) != 3: + print("Usage: %s <mail> [ outmail ]" % sys.argv[0]) + sys.exit(1) + + inmail = sys.argv[1] + if len(sys.argv) == 3: + outmail = sys.argv[2] + else: + outmail = inmail + + if hasattr(readline, 'read_history_file'): + try: + readline.read_history_file(HISTFILE) + except IOError: + pass + + # get all recorded labels for readline autocompletion + all_labels = load_labels(LABELFILE) + completer = MyCompleter(all_labels) + + # open mail and create email.message.Message object + msg = email.message_from_file(open(inmail, 'r')) + # get original labels + label_list = get_xlabel(msg) + # get user provided labels + new_label = my_input(prompt='X-Label: ', default=' '.join(label_list), + completer=completer.complete) + # write new labels to mail + write_xlabel(msg, label_list, new_label.split(), outmail) + # save readline history + readline.write_history_file(HISTFILE) + # save labels + update_labels(LABELFILE, all_labels, new_label.split()) + + +if "__main__" == __name__: + main() + diff --git a/_mutt/mutt_bgrun.sh b/_mutt/mutt_bgrun.sh new file mode 100755 index 0000000..0b2c651 --- /dev/null +++ b/_mutt/mutt_bgrun.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# @(#) mutt_bgrun $Revision: 1.4 $ + +# mutt_bgrun - run an attachment viewer from mutt in the background +# Copyright (C) 1999-2002 Gary A. Johnson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# SYNOPSIS +# mutt_bgrun viewer [viewer options] file +# +# DESCRIPTION +# Mutt invokes external attachment viewers by writing the +# attachment to a temporary file, executing the pipeline specified +# for that attachment type in the mailcap file, waiting for the +# pipeline to terminate, writing nulls over the temporary file, +# then deleting it. This causes problems when using graphical +# viewers such as qvpview and acroread to view attachments. +# +# If qvpview, for example, is executed in the foreground, the mutt +# user interface is hung until qvpview exits, so the user can't do +# anything else with mutt until he or she finishes reading the +# attachment and exits qvpview. This is especially annoying when +# a message contains several MS Office attachments--one would like +# to have them all open at once. +# +# If qvpview is executed in the background, it must be given +# enough time to completely read the file before returning control +# to mutt, since mutt will then obliterate the file. Qvpview is +# so slow that this time can exceed 20 seconds, and the bound is +# unknown. So this is again annoying. +# +# The solution provided here is to invoke the specified viewer +# from this script after first copying mutt's temporary file to +# another temporary file. This script can then quickly return +# control to mutt while the viewer can take as much time as it +# needs to read and render the attachment. +# +# EXAMPLE +# To use qvpview to view MS Office attachments from mutt, add the +# following lines to mutt's mailcap file. +# +# application/msword; mutt_bgrun qvpview %s +# application/vnd.ms-excel; mutt_bgrun qvpview %s +# application/vnd.ms-powerpoint; mutt_bgrun qvpview %s +# +# AUTHOR +# Gary A. Johnson +# <garyjohn@spk.agilent.com> +# +# ACKNOWLEDGEMENTS +# My thanks to the people who have commented on this script and +# offered solutions to shortcomings and bugs, especially Edmund +# GRIMLEY EVANS <edmundo@rano.org> and Andreas Somogyi +# <aso@somogyi.nu>. + +prog=${0##*/} + +# Check the arguments first. + +if [ "$#" -lt "2" ] +then + echo "usage: $prog viewer [viewer options] file" >&2 + exit 1 +fi + +# Separate the arguments. Assume the first is the viewer, the last is +# the file, and all in between are options to the viewer. + +viewer="$1" +shift + +while [ "$#" -gt "1" ] +do + options="$options $1" + shift +done + +file="$1" + +# Create a temporary directory for our copy of the temporary file. +# +# This is more secure than creating a temporary file in an existing +# directory. + +tmpdir=/tmp/$LOGNAME$$ +umask 077 +mkdir "$tmpdir" || exit 1 +tmpfile="$tmpdir/${file##*/}" +#echo "file: ${file}" > ~/debug.$$.log +#echo "tmpfile: ${tmpfile}" >> ~/debug.$$.log + +# Copy mutt's temporary file to our temporary directory so that we can +# let mutt overwrite and delete it when we exit. + +cp "$file" "$tmpfile" + +# Run the viewer in the background and delete the temporary files when done. + +( + "$viewer" $options "$tmpfile" > /dev/null 2>&1 + rm -f "$tmpfile" + rmdir "$tmpdir" +) & + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=sh: # diff --git a/_mutt/mutt_octet_view.sh b/_mutt/mutt_octet_view.sh new file mode 100755 index 0000000..a1e6c6f --- /dev/null +++ b/_mutt/mutt_octet_view.sh @@ -0,0 +1,278 @@ +#!/bin/sh +# @(#) mutt_octet_view $Revision: 1.1 $ + +# mutt_octet_view - select octet-stream e-mail attachment viewer +# Copyright (C) 1997,1998,1999,2000 David A Pearson +# Copyright (C) 2000-2001 Gary A. Johnson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Mutt_octet_view is derived from Dave Pearson's mutt.octet.filter +# script (http://www.hagbard.demon.co.uk/archives/mutt.octet.filter). +# Mutt.octet.filter was designed to convert octet-stream e-mail +# attachments to text for use with mutt's auto_view feature. +# Mutt_octet_view extends this capability to use different viewers from +# mutt's attachment menu, including graphical viewers if X is available. +# +# To use mutt_octet_view, put the following lines in your mailcap file: +# +# application/octet-stream; mutt_octet_view -x %s; test=RunningX +# application/octet-stream; mutt_octet_view -v %s +# application/octet-stream; mutt_octet_view %s; copiousoutput +# +# and the following line in your muttrc file: +# +# auto_view application/octet-stream +# +# Mutt_octet_view is not a viewer itself; it only selects external +# viewers based on the attachments' file name suffixes (extensions). +# In addition to any viewers, you will need a copy of the author's +# mutt_bgrun script in order to run X viewers in the background. +# +# Please direct any comments to: +# +# Gary Johnson <garyjohn@spk.agilent.com> +# + + +ShowTAR() +{ + tar tvvf "$1" 2> /dev/null +} + +ShowTGZ() +{ + tar tzvvf "$1" 2> /dev/null +} + +ShowTBZ() +{ + bzip2 -dc "$1" | tar -tvv -f- 2> /dev/null +} + +ShowGZIP() +{ + gzip -dc "$1" 2> /dev/null +} + +ShowZIP() +{ + unzip -l "$1" 2> /dev/null +} + +ShowARJ() +{ + unarj l "$1" 2> /dev/null +} + +ShowVCard() +{ + cat "$1" | mutt.vcard.filter +} + +ShowTIF() +{ + tiffinfo "$1" +} + +ShowObject() +{ + nm "$1" +} + +ShowHTML() +{ + w3m -dump "$1" +} + +ShowPDF() +{ + pdftotext "$1" - +} + +Show() +{ + case "$Mode" in + SHOW) + if [ "$2" ] + then + $2 "$1" + elif [ "$3" -o "$4" ] + then + echo "[-- $Prog: file type is unsupported for autoview (use 'v' to view this part) --]" + else + echo "[-- $Prog: file type is unsupported --]" + fi + ;; + VIEW) + if [ "$3" ] + then + $3 "$1" + elif [ "$2" ] + then + $2 "$1" + else + echo "$Prog: file type is unsupported" >&2 + exit 1 + fi + ;; + XVIEW) + if [ "$4" ] + then + mutt_bgrun $4 "$1" || $4 "$1" + elif [ "$3" ] + then + $3 "$1" + elif [ "$2" ] + then + $2 "$1" + else + echo "$Prog: file type is unsupported" >&2 + exit 1 + fi + ;; + *) echo "$Prog: internal error: invalid Mode $Mode" >&2 + exit 2;; + esac +} + +# Initialize variables + +Prog=$(basename "$0") +Mode=SHOW + +# Check option arguments + +while [ $# -gt 0 ] +do + case "$1" in + -t) Mode=SHOW; shift;; + -v) Mode=VIEW; shift;; + -x) Mode=XVIEW; shift;; + -*) echo "$Prog: invalid option $1" >&2; exit 2;; + *) break;; + esac +done + +# Check file argument + +if [ $# -ne 1 ] +then + echo "usage: $Prog [-t|-v|-x] file" + exit 2 +fi + +File=$1 + +# Process file + +# The behavior of mutt_octet_view is governed primarily by the 'Show' +# function, the option argument, and the table below. 'Show' searches +# its arguments for a command that it can use to display File. It +# begins in the table column specified by the option argument -t (the +# default), -v or -x, and searches to the left until it finds a command +# (non-empty string), which it executes. Commands in the right-most +# column are executed in the background and are left to handle their own +# output. Commands in the other two columns are executed in the +# foreground and send their output to stdout. +# +# Here are some examples. +# +# Autoview Text View X View +# (from (from (from +# index attachment attachment +# menu, menu, menu, +# in-line) foreground) background) +# (-t) (-v) (-x) +# ----------- ----------- ----------- +# Func1 "" "" Func1 will be used to display +# file in all cases. This is +# useful when all that is +# required to display the file is +# a simple text transformation. +# +# "" Func2 "" The file will not be displayed +# in the pager output from the +# index menu. Func2 will be used +# to display the file from the +# attachment menu. This is +# useful when the file is to be +# displayed as text, but is not +# normally desired to view it +# along with the rest of the +# message. +# +# "" "" Func3 The file contains graphical +# material that cannot be viewed +# as text. Func3 will be used to +# display the file only from the +# attachment menu and only when X is +# available. Func3 will be run in +# the background so that the user +# can continue to use the mailer +# while the file is displayed. +# +# "" Func2 Func3 The file contents are not +# displayed in-line along with +# the rest of the message because +# the file is typically large. +# Func2 has only text output and +# is used when only a terminal is +# available for output. Func3 +# produces a nicer display when X +# is available. + +case "$File" in + # Autoview Text View X View + # (from (from (from + # index attachment attachment + # menu, menu, menu, + # in-line) foreground) background) + # (-t) (-v) (-x) + # ----------- ----------- ------------- +*.arj | *.ARJ ) Show "$File" "" ShowARJ "" ;; +*.doc | *.DOC ) Show "$File" word2text word2text qvpview ;; +*.gif | *.GIF ) Show "$File" "" "" xv ;; +*.htm | *.HTM ) Show "$File" ShowHTML w3m mutt_netscape ;; +*.html | *.HTML ) Show "$File" ShowHTML w3m mutt_netscape ;; +*.jpeg | *.JPEG ) Show "$File" "" "" xv ;; +*.jpg | *.JPG ) Show "$File" "" "" xv ;; +*.log | *.LOG ) Show "$File" cat less "" ;; +*.o ) Show "$File" "" ShowObject "" ;; +*.pdf | *.PDF ) Show "$File" "" ShowPDF acroread ;; +*.ppt | *.PPT ) Show "$File" "" "" qvpview ;; +*.ps | *.PS ) Show "$File" "" "" ghostview ;; +*.rtf | *.RTF ) Show "$File" "" rtf2text qvpview ;; +*.tar ) Show "$File" "" ShowTAR "" ;; +*.tar.bz2 ) Show "$File" "" ShowTBZ "" ;; +*.tar.gz ) Show "$File" "" ShowTGZ "" ;; +*.tar.Z ) Show "$File" "" ShowTGZ "" ;; +*.tar.z ) Show "$File" "" ShowTGZ "" ;; +*.tbz2 ) Show "$File" "" ShowTBZ "" ;; +*.tgz ) Show "$File" "" ShowTGZ "" ;; +*.tif | *.TIF ) Show "$File" "" ShowTIF xv ;; +*.txt | *.TXT ) Show "$File" cat less "" ;; +*.url | *.URL ) Show "$File" cat w3m "" ;; +*.vcf ) Show "$File" "" ShowVCard "" ;; +*.xls | *.XLS ) Show "$File" excel2text excel2text qvpview ;; +*.Z ) Show "$File" "" ShowGZIP "" ;; +*.z ) Show "$File" "" ShowGZIP "" ;; +*.zip | *.ZIP ) Show "$File" "" ShowZIP "" ;; +*.gz ) Show "$File" "" ShowGZIP "" ;; + # The *.gz entry must follow any other entries ending in + # .gz. +* ) echo "$Prog: file type is unsupported" >&2; exit 1 ;; + +esac diff --git a/_mutt/muttrc b/_mutt/muttrc new file mode 100644 index 0000000..6b369bb --- /dev/null +++ b/_mutt/muttrc @@ -0,0 +1,251 @@ +## +## Mutt configuration +## +## Weitian LI <liweitianux@gmail.com> +## 2015/02/02 +## +## Reference: +## [1] The Homely Mutt +## http://stevelosh.com/blog/2012/10/the-homely-mutt/ +## [2] Mutt + offlineimap + notmuch + nottoomuch +## http://blog.tshirtman.fr/2013/3/17/mutt-offlineimap-notmuch-nottoomuch +## [3] ArchWiki - Mutt +## https://wiki.archlinux.org/index.php/Mutt +## [4] Using Two IMAP Accounts in Mutt +## http://pbrisbin.com/posts/two_accounts_in_mutt +## [5] The Mutt E-Mail Client +## http://www.mutt.org/doc/devel/manual.html +## [6] A Quick Guide to Mutt +## http://srobb.net/mutt.html +## [7] Multi-window Mutt with Screen +## http://op-co.de/blog/posts/mulit-window_mutt/ +## [8] Github - proycon/dotfiles - mutt with tmux +## https://github.com/proycon/dotfiles +## + +### Mail boxes +source ~/.mutt/mailboxes # Generated by OfflineIMAP + +### Mail accounts +folder-hook . source ~/.mutt/accounts/default +folder-hook 'gmail-aly.*' source ~/.mutt/accounts/gmail-aly +folder-hook 'gmail-li.*' source ~/.mutt/accounts/gmail-li +folder-hook 'outlook-aly.*' source ~/.mutt/accounts/outlook-aly +folder-hook 'outlook-li.*' source ~/.mutt/accounts/outlook-li +folder-hook 'sjtu.*' source ~/.mutt/accounts/sjtu +folder-hook 'autistici.*' source ~/.mutt/accounts/autistici +# Default account +source ~/.mutt/accounts/default + +### Files and directories +set alias_file = ~/.mutt/aliases +set certificate_file = ~/.mutt/certificates +set mailcap_path = ~/.mutt/mailcap +set history_file = ~/.mutt/history +set header_cache = ~/.mutt/cache/headers +set message_cachedir = ~/.mutt/cache/bodies +set tmpdir = ~/.mutt/tmp + +### General settings +set mbox_type = Maildir +set folder = ~/Mail +set timeout = 3 +set mail_check = 0 +set beep_new +set wrap_search # searches wrap around the end +set copy # always save a copy of outgoing messages +set delete # purge deleted messages without asking +set use_from # always generate the `From:' header field +set quit = ask-no # ask for confirmation when quit mutt +set history = 256 +set save_history = 256 +set sendmail_wait = 0 # Wait forever for sendmail to finish +unset wait_key +unset move +unset confirmappend +unset mark_old + +### Compose view +set editor = "vim +/^$/+1 -c 'set ft=mail enc=utf-8 tw=72'" +set envelope_from # which from? +set sig_dashes # dashes before my 'signature' +set autoedit # go to the editor right away when composing + # set, cannot use 'send-hooks' depend on recipients +set edit_headers # show headers when composing +set askcc # ask for CC: +set fcc_attach # save attachments with the body +set forward_format = "Fwd: %s" +set forward_quote # include message in forwards +set forward_decode # decode when forwarding +set attribution = "On %d, %n wrote:" +set fast_reply # skip to compose when replying +set reply_to # reply to 'Reply to:' field +set reverse_name # reply as whomever it was to +set include # include message in replies +#set postpone # auto postpone message not sent when exit +#set recall # prompt to recall postponed messages +unset mime_forward # forward attachments as part of body + +### Headers +ignore * +unignore from: to: cc: bcc: date: subject: X-Label: +unhdr_order * +hdr_order from: to: cc: date: subject: X-Label: + +### Encoding +set send_charset = "us-ascii:utf-8" +# if no charset given on incoming messages +set assumed_charset = "iso-8859-1:gb2312:gbk:gb18030:utf-8" +set rfc2047_parameters # to fix attachment filename encoding + +### Index view +# first bang ("!") to expand month week names in the C locale +set date_format = "!%a %m/%d %I:%M" +set index_format = "[%Z] %d %2M %-15.15L %4c%?X?[%X]& ? %s" +set folder_format = "%2C %t %N %8s %f" +set sort = threads +set sort_aux = reverse-last-date-received +set uncollapse_jump # don't collapse on an unread message +set sort_re # thread based on regex +set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*" + +### Status bar +set status_chars = " *%A" +set status_format = "---[ Folder: %f %r ]---[ Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l? %l? ]---%>-(%P)---" + +### Pager +set pager_format = "[%Z] %C/%m: %-20.20n | %s%* -- (%P)" +set pager_index_lines = 8 # number of index lines to show +set pager_context = 8 # number of context lines to show +set pager_stop # don't go to next message automatically +set menu_scroll # scroll in menus +set smart_wrap # don't split words +set tilde # show tildes like in vim +set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+" +unset markers # no ugly '+' signs for wrapped lines +alternative_order text/plain text/enriched text/html + +### Key bindings +bind index i noop +bind index <SPACE> collapse-thread +bind index p recall-message +bind index K previous-unread +bind index J next-unread +bind index,browser gg first-entry +bind index,browser G last-entry +#bind index,pager D delete-message +bind index,pager R group-reply +bind index,pager N search-opposite +bind index,pager \# noop +bind index,pager <TAB> sync-mailbox +bind pager i exit +bind pager / search +bind pager <UP> previous-line +bind pager <DOWN> next-line +bind pager k previous-line +bind pager j next-line +bind pager gg top +bind pager G bottom +bind pager K previous-undeleted +bind pager J next-undeleted +bind pager \Cj next-unread +bind attach <RETURN> view-mailcap +bind compose p pgp-menu +bind editor <TAB> complete-query +bind editor ^T complete + +### Macros +macro index q "<sync-mailbox><change-folder>?<toggle-mailboxes>" \ + "Leaves Index to folder list" +macro index \Cr "<tag-prefix><clear-flag>N" \ + "mark tagged messages as read" +macro index C "<copy-message>?<toggle-mailboxes>" \ + "copy a message to a mailbox" +macro index S "<save-message>?<toggle-mailboxes>" \ + "copy a message to a mailbox" +macro index B "<limit>~b " \ + "search message bodies" +macro index I "<change-folder>!<enter>" \ + "go to Inbox" +# Save a decoded copy in ~/ +macro index,pager > "<pipe-message>cat > ~/" \ + "save message as" +# Open in vim +macro index,pager V "<pipe-message>vim -c 'setlocal ft=mail buftype=nofile' -<enter>" \ + "open in vim" +# Sync mails with offlineimap +macro index,browser Z "<shell-escape>offlineimap -o -u ttyui<enter>" \ + "offlineimap sync ..." +macro browser q "<exit><quit>" \ + "Exit mutt" +macro browser <Tab> "<toggle-mailboxes><check-new>" \ + "Check New" +macro compose Y pfy \ + "send mail without GPG" +# urlview +macro pager \Cu "<pipe-entry>urlview<enter>" \ + "Follow links with urlview" +macro pager ';' "<exit><tag-prefix>" \ + "q+ ;" +# notmuch +macro index s "<enter-command>unset wait_key<enter><shell-escape>~/.mutt/mutt-notmuch.py -G $folder/search<enter><change-folder-readonly>+search<enter>" \ + "search mail (using notmuch)" +# labels +macro index,pager x '<enter-command>set my_oldeditor=$editor<enter><enter-command>set editor="~/.mutt/mutt-xlabel.py"<enter><edit><previous-undeleted><clear-flag>N<sync-mailbox><enter-command>set editor=$my_oldeditor<enter>' \ + "edit X-Label" +macro index \Cx "<limit>~y " \ + "limit view to label" + +### aliases +set sort_alias = alias # sort alias file by alias +set reverse_alias # show names from alias file in index +source $alias_file # enable auto-completion + +### abook +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 the sender address to abook" + +### Misc settings +## Mailing lists: lists and subscribe +set followup_to # generate 'Mail-Followup-To:' header field +set honor_followup_to # 'Mail-Followup-To' header is honored +source ~/.mutt/mailinglists + +## Multiplexing using tmux +# compose mail in tmux window +macro index,pager M '<enter-command>set my_oldeditor=$editor<enter><enter-command>set editor="cp %s %s.2; tmux new-window -a -t mutt \"~/.mutt/compose.sh %s.2\""<enter><enter-command>unset recall<enter><mail><enter-command>set editor=$my_oldeditor<enter>' \ + "mail in new tmux window" +#unset wait_key # already set above +# forward messages +# override the <recall-message> hotkey +macro index,pager P "<shell-escape>tmux new-window -a -t mutt 'mutt -F ~/.mutt/compose.rc -p'<enter>" \ + "recall postponed message in new tmux window" +# Set the editor for for editing messages in-place, +# allows re-editing before sending, e.g. for use in forwarding messages. +macro compose E '<enter-command>set my_oldeditor=$editor<enter><enter-command>set editor="vim"<enter><edit><enter-command>set editor=$my_oldeditor<enter>' \ + "edit message in-place" +# open mailbox listing in a new window +macro index,pager Y '<shell-escape>tmux new-window -a -t mutt "mutt -y"<enter>' \ + "open mailbox listing in new tmux window" + +## Attachment searching and counting +source ~/.mutt/attachments + +## Colors +source ~/.mutt/colors + +## GnuPG +source ~/.mutt/gpg.rc + +## auto view +auto_view text/html application/x-tar-gz application/x-compressed-tar \ + application/x-bzip-compressed-tar + +## MIME types that should *not* be treated according to their mailcap entry +mime_lookup application/octet-stream application/X-Lotus-Manuscript + +### Local Settings +source `FILE=$HOME/.muttrc.local; if [ ! -s "$FILE" ]; then FILE=/dev/null; fi; echo "$FILE"` + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=muttrc: # diff --git a/_mutt/ppt2text.sh b/_mutt/ppt2text.sh new file mode 100755 index 0000000..43d22f4 --- /dev/null +++ b/_mutt/ppt2text.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# +# ppt2text - convert MS PowerPoint files to ASCII text +# +# Written by Gary Johnson <garyjohn@spk.agilent.com>. +# +# Modification History: +# 2003-02-19 +# Changed the name pptHtml to ppthtml to match the xlhtml-0.5 +# release. + +prog=${0##*/} + +if [ $# -ne 1 ] +then + echo "Usage: $prog file" >&2 + exit 2 +fi + +ppthtml $1 | +w3m -dump -T text/html | +perl -pe 's/\xa0/ /g' # Change A0 spaces to ASCII + # spaces. diff --git a/_mutt/word2text.sh b/_mutt/word2text.sh new file mode 100755 index 0000000..fe9682d --- /dev/null +++ b/_mutt/word2text.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# +# word2text - convert MS Word files to ASCII text +# +# SYNOPSIS +# word2text file +# +# DESCRIPTION +# Word2text uses wvHtml, w3m and some perl glue to convert the MS +# Word file specified by the argument to ASCII text on stdout. +# +# wvHtml converts MS Word files to HTML, but is intended to be +# used with a graphical browser such as Netscape Navigator, so it +# converts certain graphical elements to image files and +# corresponding <img> tags that the browser can render. Since +# this script uses a text based browser, it uses perl to eliminate +# these <img> tags. +# +# Compared to Quick View Plus (qvpview), the rendering of MS Word +# documents done by word2text is usually more accurate. Qvpview +# doesn't render unrecognized characters well, if at all. It also +# renders numbered lists as bullet lists. +# +# Compared to the plain text translations that some people include +# in their e-mail along with the original MS Word attachments, the +# rendering done by word2text is usually more readable: vertical +# spacing between paragraphs and list items is better and the +# adjustment of text within paragraphs is better. +# +# BUGS +# wvHtml occasionally dumps core. +# With the wv-0.7.4 release, some unnumbered lists are rendered as +# numbered. +# +# AUTHOR +# Gary A. Johnson +# <garyjohn@spk.agilent.com> +# +# REVISION HISTORY +# 2003-05-31 +# Between wv-0.5.42 and wv-0.7.4, wvHtml changed to insert +# a <p> tag between each <li> tag and the following text, +# causing the list-item text to start on the line +# following the list-item bullet or number. A perl +# expression was added to this script to fix the problem. +# 2003-02-19 +# The command-line arguments to wvHtml changed, requiring +# the output file name as well as the input file name. +# Therefore, '-' (stdout) was added to the command as the +# output file name. + +wvHtml "$1" - 2> /dev/null | +perl -0777 -p -e ' + s|<img .*?>||gs; # Delete img tags. + s|(<li.*?>)\s*<p>|\1|gs; # Remove <p> tags immediately + # following <li> tags. (This + # problem appeared somewhere + # between wv-0.5.42 and + # wv-0.7.4.) +' | +w3m -dump -T text/html | +perl -p -e ' + s/\n\s*\n/\n\n/gs; # Delete extra whitespace + # between lines. + s/\xa0/ /gs; # Change A0 spaces to ASCII + # spaces. +' |