From ad704b4b8b15765b93e385c7431b19202b0bbe71 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Fri, 18 Oct 2013 21:00:48 +0600 Subject: Mail related changes. Add offlineimap and msmtp configs. Cleanup mutt configs. Changes inspired by Steve Losh post: http://stevelosh.com/blog/2012/10/the-homely-mutt/. --- files/.msmtprc | 17 ++++ files/.mutt/bindings | 39 ++++---- files/.mutt/fcc-hooks | 11 --- files/.mutt/folder-hooks.default | 9 +- files/.mutt/macros | 10 ++- files/.mutt/mailboxes | 5 +- files/.mutt/mutt-notmuch | 189 --------------------------------------- files/.mutt/mutt_mailcap | 1 + files/.mutt/muttrc | 33 +++---- files/.mutt/send-hooks | 5 -- files/.mutt/subscriptions | 14 --- files/.offlineimaprc | 36 ++++++++ 12 files changed, 96 insertions(+), 273 deletions(-) create mode 100644 files/.msmtprc delete mode 100644 files/.mutt/fcc-hooks delete mode 100755 files/.mutt/mutt-notmuch delete mode 100644 files/.mutt/send-hooks delete mode 100644 files/.mutt/subscriptions create mode 100644 files/.offlineimaprc diff --git a/files/.msmtprc b/files/.msmtprc new file mode 100644 index 0000000..72b5016 --- /dev/null +++ b/files/.msmtprc @@ -0,0 +1,17 @@ +defaults + logfile ~/Mail/msmtp.log + +account gmail + host smtp.gmail.com + from abobov@gmail.com + auth on + tls on + tls_trust_file /etc/ssl/certs/ca-certificates.crt + tls_starttls on + # Password stored in ~/.netrc + user abobov@gmail.com + port 587 + +account default: gmail + +# vim: nobackup noswapfile : diff --git a/files/.mutt/bindings b/files/.mutt/bindings index 3ed33a3..68da22c 100644 --- a/files/.mutt/bindings +++ b/files/.mutt/bindings @@ -1,29 +1,26 @@ -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 gg first-entry +bind index G last-entry +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 index F flag-message +bind index p recall-message + + +bind index,pager \CP sidebar-prev +bind index,pager \CN sidebar-next +bind index,pager \CO sidebar-open + +bind pager k previous-line +bind pager j next-line +bind pager gg top +bind pager G bottom -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 + +bind compose p postpone-message # vim: ft=muttrc diff --git a/files/.mutt/fcc-hooks b/files/.mutt/fcc-hooks deleted file mode 100644 index 30a3145..0000000 --- a/files/.mutt/fcc-hooks +++ /dev/null @@ -1,11 +0,0 @@ -# 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.default b/files/.mutt/folder-hooks.default index 1f90369..2ea8819 100644 --- a/files/.mutt/folder-hooks.default +++ b/files/.mutt/folder-hooks.default @@ -1,9 +1,10 @@ -reset index_format +set index_format="[%Z] %D %-20.20F %s" push -push '.i' # see macros for more detail +#push '.i' # see macros for more detail -set date_format="%a, %e %B %Y в %H:%M" -set attribution="В %d, %n пишет:" +set date_format="!%d %B" +set forward_format="Fwd: %s" +set attribution="On %d, %n wrote:" set from="anton@bobov.name" diff --git a/files/.mutt/macros b/files/.mutt/macros index 8eb9152..d587b71 100644 --- a/files/.mutt/macros +++ b/files/.mutt/macros @@ -2,10 +2,12 @@ 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" +macro index .i "l((~N|~O|~F)!~D)|(~d<1w!~Q)\n" "list new, flagged or one week messages" +macro index .n "l~N\n" "list only new messages" +macro index .a "l~A\n" "list all messages" +macro index .t "l~d<1d\n" "list today messages" +macro index O "offlineimap" "sync all mailboxes" +macro index o "offlineimap -qf INBOX" "sync INBOX" # Threads macros diff --git a/files/.mutt/mailboxes b/files/.mutt/mailboxes index 664c93a..2e42104 100644 --- a/files/.mutt/mailboxes +++ b/files/.mutt/mailboxes @@ -1,7 +1,8 @@ # Don't forget add rule to fcc-hooked maillists mailboxes ! -mailboxes "=[Gmail].Sent Mail" -mailboxes "=[Gmail].Drafts" +mailboxes =archive +mailboxes =sent +mailboxes =drafts # vim: ft=muttrc diff --git a/files/.mutt/mutt-notmuch b/files/.mutt/mutt-notmuch deleted file mode 100755 index e1fe909..0000000 --- a/files/.mutt/mutt-notmuch +++ /dev/null @@ -1,189 +0,0 @@ -#!/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