Muttrc

From SRS
Jump to: navigation, search

My muttrc seems to be quite popular (consistently among the top 3 hits in a google search for muttrc, looks like). It is pieced together from a whole lot of other muttrcs that I keep running across, and in any case, this weird patchwork has worked just fine for me for the last few years I've been using it. Anyway, here it is.

# .muttrc file - Suresh Ramasubramanian
# Don't display certain headers
ignore *
unignore From To Cc Subject Date Reply-To Organization X-Mailer User-Agent
# Order to display the headers in
hdr_order From: Date: To: Cc: Subject:
# Default From: line for when mailing in batch mode
my_hdr From: foo@bar.com (Foo Bar)
set imap_user="username@my.imap.server"
set imap_pass="my_imap_password"
set certificate_file=mutt.crt
set ssl_starttls=no
# Automatically begin editing messages
set autoedit=yes
set edit_headers
# Append messages to other mailboxes automatically
unset confirmappend
# Automatically delete messages
set delete=yes
# View html mails using lynx
set implicit_autoview
auto_view text/html  application/x-pgp-message
set mailcap_path="~/.mailcap"
set mailcap_sanitize=yes
# envelope sender must match
set envelope_from
# Reply FASTER!
#set fast_reply
# Don't save outgoing attachments
unset fcc_attach
# Dont include self in reply
unset reply_self
# Include full headers in replies
# set header
#set hostname - if not machine name (uname -a) 
#will be used for - among other things - making
#up message-ids
set hostname="hostname.example.com"
# Automatically quote message
set include=yes
# Set quotemark to 1 byte
set indent_str="> "
set index_format   = "%4C %Z %{%b %d} %-15.15F (%4l) %s"
set forward_format="Fw: %s"     # subject in forwarded messages
set date_format="%d/%m/%y %H:%M %Z"
set quote_regexp="^([A-Za-z ]+>|[]%>:|}-][]>:|}-]*)"
#set reply_regexp="^(re([\\[0-9\\]+])*|aw):[ \t]*"
set reply_regexp='^((re(\[[0-9]+\])?: *)?(\^+\] *)?)*'
set mime_forward=ask-yes
# Use mutt.view as my pager
# set pager=mutt.view
set edit_headers
# Use vim as the editor - this line will wrap
# Set wordwrap on in vim to automatically wrap lines - 
# no :gq all the time
set editor="vim +':set textwidth=77' +':set wrap' +\`awk '/^$/ {print i+2; exit} {i++}' %s\` %s" 
#set visual=vim                 # editor invoked by ~v in the builtin editor
# set format=flowed
set text_flowed
# dont mark messages old
set nomark_old
# Location for postponed messages
set postponed="=postponed"
# I don't want to resume postponed messages
#set recall=no
# Save copies of outgoing e-mail
set record="=sent-mail"
# Don't confirm using Reply-To: headers
set reply_to=yes
# Delete empty mailboxes
unset save_empty
# Use as from the address mail was sent to
# You'd have to define $alternates for this
# set reverse_name
# Set my web browser
#set web_browser="lynx %s"
# Save mail to =received when I press ">", like in Elm
set mbox="=received"
# Apply operations to tagged messages automatically
set auto_tag
# Define the directory where mutt looks for mailboxes to
# report new mail
mailboxes `echo $HOME/mail/*`
# Tell mutt which mails to recognize as mailing lists
subscribe linux
subscribe freebsd
folder-hook . set sort=threads
folder-hook . set signature="~/sig.suresh|"
folder-hook . 'set attribution="+++ %n [%d]:"'
folder-hook . my_hdr From: foo@bar.com (Foo Bar)
folder-hook . my_hdr Organization: Eh? What's that?
folder-hook . my_hdr X-OS: `uname -mnrs`
# Ignore annoying MAIL SYSTEM INTERNAL DATA message
# generated by c-client (pine / uw-imapd)
folder-hook . "push \"l!(~s 'FOLDER INTERNAL DATA')\n*\""
#folder-hook linux unmy_hdr reply-to
folder-hook linux 'set attribution="+++ %n [linux] [%d]:"'
folder-hook linux my_hdr From: linux@bar.com (Foo Linux)
folder-hook linux my_hdr Organization: -ENOENT
folder-hook linux set signature="~/sig.unix|"
folder-hook freebsd set signature="~/sig.unix|"
folder-hook freebsd 'set attribution="+++ %n [freebsd] [%d]:"'
folder-hook freebsd my_hdr From: freebsd@bar.com (Foo FreeBSD)
folder-hook freebsd my_hdr Organization: Hmmm... I dunno
# color patterns for mutt
color normal     white          black # normal text
color indicator  yellow         default # actual message
color tree       brightmagenta  default # thread arrows
color status     yellow         default # status line
color error      brightred      default # errors
color message    magenta        default # info messages
color signature  magenta        default # signature
color attachment brightyellow   red     # MIME attachments
color search     brightyellow   red     # search matches
color tilde      brightmagenta  default # ~ at bottom of msg
color markers    red            default # + at beginning of wrapped lines
color hdrdefault cyan           default # default header lines
color bold       red            default # hiliting bold patterns in body
color underline  green          default # hiliting underlined patterns in body
color quoted     cyan           default # quoted text
color quoted1    magenta        default
color quoted2    red            default
color quoted3    green          default
color quoted4    magenta           default
color quoted5    cyan           default
color quoted6    magenta        default
color quoted7    red            default
color quoted8    green          default
color quoted9    cyan           default
color body   cyan  default  "((ftp|http|https)://|news:)[^ >)\"\t]+"
color body   cyan  default  "[-a-z_0-9.+]+@[-a-z_0-9.]+"
color body   red   default  "(^| )\\*[-a-z0-9*]+\\*[,.?]?[ \n]"
color body   green default  "(^| )_[-a-z0-9_]+_[,.?]?[\n]"
color body   red   default  "(^| )\\*[-a-z0-9*]+\\*[,.?]?[ \n]"
color body   green default  "(^| )_[-a-z0-9_]+_[,.?]?[ \n]"
color index  cyan  default  ~F         # Flagged
color index  red   default  ~N         # New
color index  magenta    default  ~T         # Tagged
color index  cyan       default  ~D         # Deleted
# Don't ask to move read messages to mbox on exit
set move=no
###
# Bindings - change key bindings
###
# Customize the pager
bind pager [ previous-line
bind pager < previous-line
bind pager ] next-line
bind pager > next-line
bind pager down next-page
bind pager up previous-page
# dual window view in mutt
# set pager_index_lines=10
# Similar settings for the index
bind index [ previous-line
bind index ] next-line
# imitate the old search-body function
macro index \eb '/~b ' 'search in message bodies'
# simluate the old url menu
macro index \cb |urlview\n 'call urlview to extract URLs out of a message'
macro pager \cb |urlview\n 'call urlview to extract URLs out of a message'
# Show documentation when pressing F1
macro generic <f1> "!less /usr/doc/mutt/manual.txt\n" "Show Mutt documentation"
macro index   <f1> "!less /usr/doc/mutt/manual.txt\n" "Show Mutt documentation"
macro pager   <f1> "!less /usr/doc/mutt/manual.txt\n" "Show Mutt documentation"
# Set and source our alias file
set alias_file=~/.mutt-aliases
source ~/.mutt-aliases
# pgp stuff - Snarfed from Roland Rosenfeld http://www.spinnaker.de
# For Mutt 1.3.x versions only - go to his website if you want the
# version for older (1.2.5i say) mutts
source ~/gpg.rc
set fcc_clear
set forward_decrypt
unset pipe_decode
set pgp_ignore_subkeys  # On OpenPGP keys only show the main key, not the sub.
unset pgp_autosign      # pgp sign every outgoing mail. (send-hook?)
unset pgp_autoencrypt   # pgp encrypt every outgoing mail. (send-hook?)
set pgp_create_traditional=ask-no       # Use old-style PGP? (don't do it!)
set pgp_replyencrypt    # Encrypt replies on encrypted mail
set pgp_replysign       # Sign replies on signed mail
set pgp_replysignencrypted      # Sign replies on encrypted mail
unset pgp_retainable_sigs       # disable retainable signatures.
set pgp_verify_sig=yes  # ask me whether I want to check a pgp signature
set pgp_timeout=7200    # forget PGP passphrase after 7200 seconds (=2 hours)
set pgp_strict_enc      # allway use QP enc. with PGP.
unset pgp_long_ids      # display 64bit PGP key-ids (don't change this!)
set pgp_show_unusable   # show unusable PGP keys in menu
# %n = number   %k = key id     %K = key id of the principal key
# %u = user id  %a = algorithm  %A = algorithm of the princ. key
# %l = length   %L = length of the princ. key
# %f = flags    %F = flags of the princ. key
# %c = capabilities             %C = capabilities of the princ. key
# %t = trust/validity of the key-uid association
set pgp_entry_format="%4n %t%f %[%y/%m/%d] %4l/0x%k %-4a %2c %u"
set pgp_sort_keys=trust
# Once you are done with composing a mail in vim, and
# before you press y to send out an email, just press
# S and enter your PGP passphrase to pgp-clearsign an
# email.  Mutt uses PGP-MIME signatures by default, and
# several clients (most notably windows clients) absolutely
# hate the very idea of PGP-MIME :(
# Put your gpg key id below instead of my key 0xEDEDEFB9
macro compose S "Fgpg -a --clearsign -u 0xEDEDEFB9"

See that a file called .mutt-aliases exists in your home directory when you start mutt (or it will bitch that it can't find it). Just enter "touch .mutt-aliases" at your shell prompt, or add addresses by yourself in the format

alias joe Joe Blow <joe.blow@warez.slashdot.org>

Of course, you can just press "a" when viewing a message and you'll be able to add the sender to your alias file.

sig.unix or whatever would look like this - change the paths if they don't fit your distro

   #!/bin/bash
   cat .signature
   /usr/games/fortune lost

This just prints out a short signature file - and then adds a random fortune cookie to the bottom of the sig. "fortune lost" uses a fortune file generated from [LOST] the now defunct Linux One Stanza Tips project.

You then need a couple of other files - gpg.rc and .mailcap ... you also need another binary - [gpg-2comp]

gpg.rc

Courtesy [Roland Rosenfeld]

# -*-muttrc-*-
#
# Command formats for gpg.
# 
# This version uses gpg-2comp from 
#   http://muppet.faveve.uni-stuttgart.de/~gero/gpg-2comp/
#
# $ Id: gpg.rc,v 1.7 2000/02/02 10:40:59 roland Exp roland $
#
# %p    The empty string when no passphrase is needed,
#       the string "PGPPASSFD=0" if one is needed.
#
#       This is mostly used in conditional % sequences.
#
# %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.
# decode application/pgp
set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch -o - %f"
# verify a pgp/mime signature
set pgp_verify_command="gpg --no-verbose --batch -o - --verify %s %f"
# decrypt a pgp/mime attachment
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
# create a pgp/mime signed attachment
set pgp_sign_command="gpg-2comp --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
# create a application/pgp signed (old-style) message
set pgp_clearsign_command="gpg-2comp --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
# create a pgp/mime encrypted attachment
set pgp_encrypt_only_command="pgpewrap gpg-2comp -v --batch --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
# create a pgp/mime encrypted and signed attachment
set pgp_encrypt_sign_command="pgpewrap gpg-2comp --passphrase-fd 0 -v --batch -o - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
# import a key into the public key ring
set pgp_import_command="gpg --no-verbose --import -v %f"
# export a key from the public key ring
set pgp_export_command="gpg --no-verbose --export --armor %r"
# verify a key
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
# read in the public key ring
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
# read in the secret key ring
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
# receive key from keyserver:
#set pgp_getkeys_command="wrap.sh -g %r"
set pgp_getkeys_command=""
# string that the verify command outputs if the signature is good
#set pgp_good_sign="Good signature"     # English version
set pgp_good_sign=""                    # not needed, if exit code ok.

.mailcap

All this assumes you have gpg, lynx, and other related apps installed

text/html;lynx -dump %s; nametemplate=%s.html; copiousoutput
application/vnd.sun.xml.writer;/usr/bin/ooffice2 %s
application/vnd.sun.xml.writer.global;/usr/bin/ooffice2 %s
application/vnd.stardivision.writer;/usr/bin/ooffice2 %s
application/vnd.stardivision.writer-global;/usr/bin/ooffice2 %s
application/x-starwriter;/usr/bin/ooffice2 %s
application/vnd.sun.xml.writer.template;/usr/bin/ooffice2 %s
application/msword;/usr/bin/ooffice2 %s
application/vnd.sun.xml.calc;/usr/bin/ooffice2 %s
application/vnd.stardivision.calc;/usr/bin/ooffice2 %s
application/x-starcalc;/usr/bin/ooffice2 %s
application/vnd.sun.xml.calc.template;/usr/bin/ooffice2 %s
application/excel;/usr/bin/ooffice2 %s
application/msexcel;/usr/bin/ooffice2 %s
application/vnd.ms-excel;/usr/bin/ooffice2 %s
application/x-msexcel;/usr/bin/ooffice2 %s
application/vnd.sun.xml.impress;/usr/bin/ooffice2 %s
application/vnd.stardivision.impress;/usr/bin/ooffice2 %s
application/vnd.stardivision.impress-packed;/usr/bin/ooffice2 %s
application/x-starimpress;/usr/bin/ooffice2 %s
application/vnd.sun.xml.impress.template;/usr/bin/ooffice2 %s
application/powerpoint;/usr/bin/ooffice2 %s
application/mspowerpoint;/usr/bin/ooffice2 %s
application/vnd.ms-powerpoint;/usr/bin/ooffice2 %s
application/x-mspowerpoint;/usr/bin/ooffice2 %s
application/vnd.sun.xml.draw;/usr/bin/ooffice2 %s
application/vnd.stardivision.draw;/usr/bin/ooffice2 %s
application/x-stardraw;/usr/bin/ooffice2 %s
application/vnd.sun.xml.draw.template;/usr/bin/ooffice2 %s
application/vnd.sun.xml.math;/usr/bin/ooffice2 %s
application/vnd.stardivision.math;/usr/bin/ooffice2 %s
application/x-starmath;/usr/bin/ooffice2 %s
audio/x-pn-realaudio;/usr/local/RealPlayer8/realplay "%u"
audio/vnd.rn-realaudio;/usr/local/RealPlayer8/realplay "%u"
application/smil;/usr/local/RealPlayer8/realplay "%u"
text/vnd.rn-realtext;/usr/local/RealPlayer8/realplay "%u"
video/vnd.rn-realvideo;/usr/local/RealPlayer8/realplay "%u"
image/vnd.rn-realflash;/usr/local/RealPlayer8/realplay "%u"
application/x-shockwave-flash2-preview;/usr/local/RealPlayer8/realplay "%u"
application/sdp;/usr/local/RealPlayer8/realplay "%u"
application/x-sdp;/usr/local/RealPlayer8/realplay "%u"
application/vnd.rn-realmedia;/usr/local/RealPlayer8/realplay "%u"
image/vnd.rn-realpix;/usr/local/RealPlayer8/realplay "%u"
audio/wav;/usr/local/RealPlayer8/realplay "%u"
audio/x-wav;/usr/local/RealPlayer8/realplay "%u"
audio/x-pn-wav;/usr/local/RealPlayer8/realplay "%u"
audio/x-pn-windows-acm;/usr/local/RealPlayer8/realplay "%u"
audio/basic;/usr/local/RealPlayer8/realplay "%u"
audio/x-pn-au;/usr/local/RealPlayer8/realplay "%u"
audio/aiff;/usr/local/RealPlayer8/realplay "%u"
audio/x-aiff;/usr/local/RealPlayer8/realplay "%u"
audio/x-pn-aiff;/usr/local/RealPlayer8/realplay "%u"
audio/x-pn-realaudio-plugin;/usr/bin/gxine %s
audio/x-real-audio;/usr/bin/gxine %s
audio/x-ogg;/usr/bin/gxine %s
audio/x-speex;/usr/bin/gxine %s
application/x-ogg;/usr/bin/gxine %s
application/x-annodex;/usr/bin/gxine %s
image/png;/usr/bin/gxine %s
image/x-png;/usr/bin/gxine %s
video/mng;/usr/bin/gxine %s
video/x-mng;/usr/bin/gxine %s
audio/x-8svx;/usr/bin/gxine %s
audio/8svx;/usr/bin/gxine %s
audio/x-16sv;/usr/bin/gxine %s
audio/168sv;/usr/bin/gxine %s
image/x-ilbm;/usr/bin/gxine %s
image/ilbm;/usr/bin/gxine %s
video/x-anim;/usr/bin/gxine %s
video/anim;/usr/bin/gxine %s
audio/mpeg2;/usr/bin/gxine %s
audio/x-mpeg2;/usr/bin/gxine %s
audio/mpeg3;/usr/bin/gxine %s
audio/x-mpeg3;/usr/bin/gxine %s
audio/mpeg;/usr/bin/gxine %s
audio/x-mpeg;/usr/bin/gxine %s
x-mpegurl;/usr/bin/gxine %s
audio/mpegurl;/usr/bin/gxine %s
audio/mp3;/usr/bin/gxine %s
audio/x-mp3;/usr/bin/gxine %s
audio/x-realaudio;/usr/bin/gxine %s
audio/x-basic;/usr/bin/gxine %s
video/x-flic;/usr/bin/gxine %s
video/msvideo;/usr/bin/gxine %s
video/x-msvideo;/usr/bin/gxine %s
video/x-ms-asf;/usr/bin/gxine %s
video/x-ms-wmv;/usr/bin/gxine %s
video/x-ms-wma;/usr/bin/gxine %s
application/vnd.ms-asf;/usr/bin/gxine %s
application/x-mplayer2;/usr/bin/gxine %s
video/x-ms-asf-plugin;/usr/bin/gxine %s
video/x-ms-wvx;/usr/bin/gxine %s
video/x-ms-wax;/usr/bin/gxine %s
video/mkv;/usr/bin/gxine %s
video/mpeg;/usr/bin/gxine %s
video/x-mpeg;/usr/bin/gxine %s
video/quicktime;/usr/bin/gxine %s
video/x-quicktime;/usr/bin/gxine %s
audio/x-m4a;/usr/bin/gxine %s
application/x-quicktimeplayer;/usr/bin/gxine %s