From b63ddd9406eabce7887ae13057732c9672b3fd75 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Mon, 17 Oct 2011 11:54:08 +0600 Subject: f --- .gitignore | 2 + files/.mutt/bindings | 29 ++++ files/.mutt/colors | 33 ++++ files/.mutt/crypto | 43 +++++ files/.mutt/fcc-hooks | 11 ++ files/.mutt/folder-hooks | 3 + files/.mutt/folder-hooks.default | 10 ++ files/.mutt/folder-hooks.maillist | 8 + files/.mutt/gen_maillist.sh | 45 ++++++ files/.mutt/macros | 16 ++ files/.mutt/mailboxes | 9 ++ files/.mutt/maillists | 18 +++ files/.mutt/maillists.generate | 82 ++++++++++ files/.mutt/mutt-notmuch | 189 ++++++++++++++++++++++ files/.mutt/mutt.octet.filter | 328 ++++++++++++++++++++++++++++++++++++++ files/.mutt/mutt_mailcap | 6 + files/.mutt/muttrc | 139 ++++++++++++++++ files/.mutt/send-hooks | 5 + files/.mutt/signature | 2 + files/.mutt/subscriptions | 14 ++ 20 files changed, 992 insertions(+) create mode 100644 files/.mutt/bindings create mode 100644 files/.mutt/colors create mode 100644 files/.mutt/crypto create mode 100644 files/.mutt/fcc-hooks create mode 100644 files/.mutt/folder-hooks create mode 100644 files/.mutt/folder-hooks.default create mode 100644 files/.mutt/folder-hooks.maillist create mode 100755 files/.mutt/gen_maillist.sh create mode 100644 files/.mutt/macros create mode 100644 files/.mutt/mailboxes create mode 100644 files/.mutt/maillists create mode 100644 files/.mutt/maillists.generate create mode 100755 files/.mutt/mutt-notmuch create mode 100755 files/.mutt/mutt.octet.filter create mode 100644 files/.mutt/mutt_mailcap create mode 100644 files/.mutt/muttrc create mode 100644 files/.mutt/send-hooks create mode 100644 files/.mutt/signature create mode 100644 files/.mutt/subscriptions diff --git a/.gitignore b/.gitignore index f19fbac..0bdff0c 100755 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ files/.zsh/cache +files/.mutt/aliases +files/.mutt/certificates diff --git a/files/.mutt/bindings b/files/.mutt/bindings new file mode 100644 index 0000000..3ed33a3 --- /dev/null +++ b/files/.mutt/bindings @@ -0,0 +1,29 @@ +bind generic first-entry +bind generic last-entry +bind generic previous-entry +bind generic next-entry +bind generic "(" current-top + +bind index "{" previous-thread +bind index "}" next-thread +bind index previous-thread +bind index next-thread +bind index - collapse-thread +bind index "F" flag-message +bind index \CP sidebar-prev +bind index \CN sidebar-next +bind index \CO sidebar-open + +bind pager top +bind pager bottom +bind pager "{" previous-thread +bind pager "}" next-thread +bind pager previous-line +bind pager next-line +bind pager previous-entry +bind pager next-entry +bind pager \CP sidebar-prev +bind pager \CN sidebar-next +bind pager \CO sidebar-open + +# vim: ft=muttrc diff --git a/files/.mutt/colors b/files/.mutt/colors new file mode 100644 index 0000000..227119d --- /dev/null +++ b/files/.mutt/colors @@ -0,0 +1,33 @@ +## +# Colors +# + +color hdrdefault black cyan +color quoted brightred black +color signature magenta black +color indicator brightwhite red +color attachment black green +color error red black +color message white black +color search brightwhite magenta +color status brightyellow magenta +color tree red black +color normal white black +color tilde green black +color bold brightyellow black +color markers red black + +# Highlights inside body of msg. +color body brightblue black "(http|ftp)://[^ \"\t\r\n]*" +color body brightblue black "mailto:[-a-z_0-9.]+@[-a-z0-9.]+" +color body brightblue black "[-a-z_0-9.]+@[-a-z0-9_.]+" +color body brightgreen black " [:;]-*[)>(<|]" + +color header brightwhite cyan "^(From|Subject):" + +color index green black ~p +color index black yellow ~F + +color sidebar_new yellow default + +# vim: ft=muttrc diff --git a/files/.mutt/crypto b/files/.mutt/crypto new file mode 100644 index 0000000..217d15a --- /dev/null +++ b/files/.mutt/crypto @@ -0,0 +1,43 @@ +set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f" +set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f" +set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f" +set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f" +set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f" +set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xC9C40C31 -- -r %r -- %f" +set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xC9C40C31 -- -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=0x0DA8C91F + +# 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 outcoming messages +set crypt_autosign +# sign only replies to signed messages +set crypt_replysign + +## automatically encrypt outcoming messages +#set crypt_autoencrypt=yes +## 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=no + +# vim: ft=muttrc diff --git a/files/.mutt/fcc-hooks b/files/.mutt/fcc-hooks new file mode 100644 index 0000000..30a3145 --- /dev/null +++ b/files/.mutt/fcc-hooks @@ -0,0 +1,11 @@ +# vim: ft=muttrc +# Fcc hooks, everything else goes to $record +# + +# Lists +#fcc-save-hook '~t mutt-user' =ml_mutt +#fcc-save-hook '~t vim' =ml_vim +#fcc-save-hook '~t gentoo-user@lists.gentoo.org' =ml_gentoo_user +# fcc-save-hook '~t gentoo-user-ru@lists.gentoo.org' =ml_gentoo_user_ru +#fcc-save-hook '~t awesome@naquadah.org' =ml_awesome +# fcc-save-hook '~t cygwin@cygwin.com' =ml_cygwin diff --git a/files/.mutt/folder-hooks b/files/.mutt/folder-hooks new file mode 100644 index 0000000..70baacd --- /dev/null +++ b/files/.mutt/folder-hooks @@ -0,0 +1,3 @@ +folder-hook . source ~/.mutt/folder-hooks.default + +# vim: ft=muttrc diff --git a/files/.mutt/folder-hooks.default b/files/.mutt/folder-hooks.default new file mode 100644 index 0000000..1f90369 --- /dev/null +++ b/files/.mutt/folder-hooks.default @@ -0,0 +1,10 @@ +reset index_format +push +push '.i' # see macros for more detail + +set date_format="%a, %e %B %Y в %H:%M" +set attribution="В %d, %n пишет:" + +set from="anton@bobov.name" + +# vim: ft=muttrc diff --git a/files/.mutt/folder-hooks.maillist b/files/.mutt/folder-hooks.maillist new file mode 100644 index 0000000..eb14428 --- /dev/null +++ b/files/.mutt/folder-hooks.maillist @@ -0,0 +1,8 @@ +set index_format="%Z %{%b %d} %-15.15n (%4E) %s" + +reset attribution +set date_format="!%a, %b %d, %Y at %H:%M:%S %Z" + +set from="abobov@gmail.com" + +# vim: ft=muttrc diff --git a/files/.mutt/gen_maillist.sh b/files/.mutt/gen_maillist.sh new file mode 100755 index 0000000..89e13c7 --- /dev/null +++ b/files/.mutt/gen_maillist.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +CONFIG=$(dirname $0)/maillists +RESULT=maillists.generate +FOLDER_HOOK=folder-hooks.maillist + +die() { + echo $1 + exit 1 +} + +add_maillist() { + email=$1 + mailbox=$2 + + echo "# email: $email" + echo "# mailbox: $mailbox" + + # Subscription + echo "subscribe $email" + # Mailboxes + echo "mailboxes \"$mailbox\"" + # Folder hook + echo "folder-hook \"$mailbox\" source $FOLDER_HOOK" + # FCC hook + echo "fcc-hook $email \"$mailbox\"" + + printf "\n\n" +} + +test -f "$CONFIG" || die "Config file ($RESULT) not exists." + +echo "# Generate date: $(date)" > "$RESULT" || die "Can't write file ($RESULT)." +echo "# vim: ft=muttrc :" >> "$RESULT" + +while read email mailbox +do + if [[ -n "$email" ]] + then + if [[ "$(echo $email | sed 's/^\s*#//')" == "$email" ]] + then + add_maillist $email $mailbox >> "$RESULT" + fi + fi +done < "${CONFIG}" diff --git a/files/.mutt/macros b/files/.mutt/macros new file mode 100644 index 0000000..8eb9152 --- /dev/null +++ b/files/.mutt/macros @@ -0,0 +1,16 @@ +macro index,pager S "=[Gmail]/Spam" "mark message as spam" +macro index ,r "~NN." "mark all new messages read" +#macro index,pager H "=INBOX" "mark message as ham" + +macro index .i "l((~N|~O|~F)!~D)|(~d<1w!~Q)\n" +macro index .n "l~N\n" +macro index .a "l~A\n" +macro index .t "l~d<1d\n" + +# Threads macros + +macro index,pager za "v" +macro index,pager zr "V" +macro index,pager zm "V" + +# vim: ft=muttrc diff --git a/files/.mutt/mailboxes b/files/.mutt/mailboxes new file mode 100644 index 0000000..52da56a --- /dev/null +++ b/files/.mutt/mailboxes @@ -0,0 +1,9 @@ +# Don't forget add rule to fcc-hooked maillists + +mailboxes ! +mailboxes "=[Gmail].Sent Mail" +mailboxes "=[Gmail].Drafts" +mailboxes "=softdata" +mailboxes "/var/spool/mail/dexter" + +# vim: ft=muttrc diff --git a/files/.mutt/maillists b/files/.mutt/maillists new file mode 100644 index 0000000..3bb0e04 --- /dev/null +++ b/files/.mutt/maillists @@ -0,0 +1,18 @@ +# Maillist subscriptions +# +# Format: +# email mailbox + +mutt-users@mutt.org =ml_mutt +vim@vim.org =ml_vim +gentoo-user@lists.gentoo.org =ml_gentoo_user +gentoo-user-ru@lists.gentoo.org =ml_gentoo_user_ru +awesome@naquadah.org =ml_awesome +rxvt-unicode@lists.schmorp.de =ml_urxvt +cygwin@cygwin.com =ml_cygwin +google-web-toolkit@googlegroups.com =ml_gwt +trac-users@googlegroups.com =ml_trac +tmux-users@lists.sourceforge.net =ml_tmux + + +# vim: ft=conf : diff --git a/files/.mutt/maillists.generate b/files/.mutt/maillists.generate new file mode 100644 index 0000000..d7c7f36 --- /dev/null +++ b/files/.mutt/maillists.generate @@ -0,0 +1,82 @@ +# Generate date: Mon Oct 17 11:49:14 2011 +# vim: ft=muttrc : +# email: mutt-users@mutt.org +# mailbox: =ml_mutt +subscribe mutt-users@mutt.org +mailboxes "=ml_mutt" +folder-hook "=ml_mutt" source folder-hooks.maillist +fcc-hook mutt-users@mutt.org "=ml_mutt" + + +# email: vim@vim.org +# mailbox: =ml_vim +subscribe vim@vim.org +mailboxes "=ml_vim" +folder-hook "=ml_vim" source folder-hooks.maillist +fcc-hook vim@vim.org "=ml_vim" + + +# email: gentoo-user@lists.gentoo.org +# mailbox: =ml_gentoo_user +subscribe gentoo-user@lists.gentoo.org +mailboxes "=ml_gentoo_user" +folder-hook "=ml_gentoo_user" source folder-hooks.maillist +fcc-hook gentoo-user@lists.gentoo.org "=ml_gentoo_user" + + +# email: gentoo-user-ru@lists.gentoo.org +# mailbox: =ml_gentoo_user_ru +subscribe gentoo-user-ru@lists.gentoo.org +mailboxes "=ml_gentoo_user_ru" +folder-hook "=ml_gentoo_user_ru" source folder-hooks.maillist +fcc-hook gentoo-user-ru@lists.gentoo.org "=ml_gentoo_user_ru" + + +# email: awesome@naquadah.org +# mailbox: =ml_awesome +subscribe awesome@naquadah.org +mailboxes "=ml_awesome" +folder-hook "=ml_awesome" source folder-hooks.maillist +fcc-hook awesome@naquadah.org "=ml_awesome" + + +# email: rxvt-unicode@lists.schmorp.de +# mailbox: =ml_urxvt +subscribe rxvt-unicode@lists.schmorp.de +mailboxes "=ml_urxvt" +folder-hook "=ml_urxvt" source folder-hooks.maillist +fcc-hook rxvt-unicode@lists.schmorp.de "=ml_urxvt" + + +# email: cygwin@cygwin.com +# mailbox: =ml_cygwin +subscribe cygwin@cygwin.com +mailboxes "=ml_cygwin" +folder-hook "=ml_cygwin" source folder-hooks.maillist +fcc-hook cygwin@cygwin.com "=ml_cygwin" + + +# email: google-web-toolkit@googlegroups.com +# mailbox: =ml_gwt +subscribe google-web-toolkit@googlegroups.com +mailboxes "=ml_gwt" +folder-hook "=ml_gwt" source folder-hooks.maillist +fcc-hook google-web-toolkit@googlegroups.com "=ml_gwt" + + +# email: trac-users@googlegroups.com +# mailbox: =ml_trac +subscribe trac-users@googlegroups.com +mailboxes "=ml_trac" +folder-hook "=ml_trac" source folder-hooks.maillist +fcc-hook trac-users@googlegroups.com "=ml_trac" + + +# email: tmux-users@lists.sourceforge.net +# mailbox: =ml_tmux +subscribe tmux-users@lists.sourceforge.net +mailboxes "=ml_tmux" +folder-hook "=ml_tmux" source folder-hooks.maillist +fcc-hook tmux-users@lists.sourceforge.net "=ml_tmux" + + diff --git a/files/.mutt/mutt-notmuch b/files/.mutt/mutt-notmuch new file mode 100755 index 0000000..e1fe909 --- /dev/null +++ b/files/.mutt/mutt-notmuch @@ -0,0 +1,189 @@ +#!/usr/bin/perl -w +# +# mutt-notmuch - notmuch (of a) helper for Mutt +# +# Copyright: © 2011 Stefano Zacchiroli +# License: GNU General Public License (GPL), version 3 or above +# +# See the bottom of this file for more documentation. +# A manpage can be obtained by running "pod2man mutt-notmuch > mutt-notmuch.1" + +use strict; +use warnings; + +use File::Path; +use Getopt::Long; +use Mail::Internet; +use Mail::Box::Maildir; +use Pod::Usage; + + +# create an empty maildir (if missing) or empty an existing maildir" +sub empty_maildir($) { + my ($maildir) = (@_); + rmtree($maildir) if (-d $maildir); + my $folder = new Mail::Box::Maildir(folder => $maildir, + create => 1); + $folder->close(); +} + +# search($maildir, $query) +# search mails according to $query with notmuch; store results in $maildir +sub search($$) { + my ($maildir, $query) = @_; + + empty_maildir($maildir); + system("notmuch search --output=files $query" + . " | xargs --no-run-if-empty ln -s -t $maildir/cur/"); +} + +sub search_action($$@) { + my ($interactive, $results_dir, @params) = @_; + + if (! $interactive) { + search($results_dir, join(' ', @params)); + } else { + my $query = ""; + my $done = 0; + while (! $done) { + print "search ('?' for man): "; + chomp($query = ); + if ($query eq "?") { + system("man notmuch"); + } elsif ($query eq "") { + $done = 1; # quit doing nothing + } else { + search($results_dir, $query); + $done = 1; + } + } + } +} + +sub thread_action(@) { + my ($results_dir, @params) = @_; + + my $mail = Mail::Internet->new(\*STDIN); + $mail->head->get('message-id') =~ /^<(.*)>$/; # get message-id + my $mid = $1; + my $tid = `notmuch search --output=threads id:$mid`;# get thread id + chomp($tid); + + search($results_dir, $tid); +} + +sub die_usage() { + my %podflags = ( "verbose" => 1, + "exitval" => 2 ); + pod2usage(%podflags); +} + +sub main() { + my $results_dir = "$ENV{HOME}/.cache/mutt_results"; + my $interactive = 0; + my $help_needed = 0; + + my $getopt = GetOptions( + "h|help" => \$help_needed, + "o|output-dir=s" => \$results_dir, + "p|prompt" => \$interactive); + if (! $getopt || $#ARGV < 0) { die_usage() }; + my ($action, @params) = ($ARGV[0], @ARGV[1..$#ARGV]); + + if ($help_needed) { + die_usage(); + } elsif ($action eq "search" && $#ARGV == 0 && ! $interactive) { + print STDERR "Error: no search term provided\n\n"; + die_usage(); + } elsif ($action eq "search") { + search_action($interactive, $results_dir, @params); + } elsif ($action eq "thread") { + thread_action($results_dir, @params); + } else { + die_usage(); + } +} + +main(); + +__END__ + +=head1 NAME + +mutt-notmuch - notmuch (of a) helper for Mutt + +=head1 SYNOPSIS + +=over + +=item B [I