From b2b1099546e48501bfea78f2502ec04f1e4d30d8 Mon Sep 17 00:00:00 2001 From: Orien Vandenbergh Date: Fri, 2 May 2025 10:17:28 -0400 Subject: [PATCH] Some further mutt tweaks --- neomutt/mailboxes | 4 +- neomutt/neomuttrc | 1 + neomutt/save-hooks | 7 +++- scripts/mutt-mailhops | 97 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100755 scripts/mutt-mailhops diff --git a/neomutt/mailboxes b/neomutt/mailboxes index eb65395..b914670 100644 --- a/neomutt/mailboxes +++ b/neomutt/mailboxes @@ -20,6 +20,6 @@ set postponed="+[Gmail]/Drafts" # Look me up set spoolfile="+INBOX" -mailboxes "+INBOX" +mailboxes $spoolfile + set imap_check_subscribed = yes -#mailboxes "imaps://imap.gmail.com/AdminTickets" diff --git a/neomutt/neomuttrc b/neomutt/neomuttrc index 7a13d11..918cd29 100644 --- a/neomutt/neomuttrc +++ b/neomutt/neomuttrc @@ -25,6 +25,7 @@ set editor="vim -c ':0' -c '/^$/' -c ':nohlsearch'" #set query_command="lbdbq '%s'" # Use the little brother database for doing queries. set mark_old # Don't mark unread new msgs as old. set mail_check=90 +set mail_check_recent set timeout=15 set mbox_type=maildir # mailbox type set mbox="!" # Default mailbox. diff --git a/neomutt/save-hooks b/neomutt/save-hooks index cdf882c..66b97e4 100644 --- a/neomutt/save-hooks +++ b/neomutt/save-hooks @@ -4,4 +4,9 @@ # #save-hook .* =Archive/`date "+%Y"`/`date "+%m"` -save-hook .* "=[Gmail]/All Mail" +save-hook '~f @nafinc\\.com$' "=Customers/NAF" +save-hook '~f @newyorklife\\.com$' "=Customers/NYLife" +save-hook '=f @rtx.com' "=Customers/RTX" +save-hook '=f @shu.edu' "=Customers/SHU" +save-hook '=f @partner.paloaltonetworks.com' "=Partners/PaloAlto" +save-hook '.*' "=[Gmail]/All Mail" diff --git a/scripts/mutt-mailhops b/scripts/mutt-mailhops new file mode 100755 index 0000000..4da33ad --- /dev/null +++ b/scripts/mutt-mailhops @@ -0,0 +1,97 @@ +#!/usr/bin/perl -w +# Copyright (c) 1999 Marius Gedminas +# Shows the route of an Internet mail message +# Version 0.0.1pre-alpha +# +# Patched by Roland Rosenfeld +# $ Id: mailhops,v 1.3 2000/01/25 20:18:24 roland Exp roland $ + +use strict; +use POSIX qw(mktime); +use Date::Parse; + +my $verbose = 0; + +# Setup +my %Months = ( + Jan => 1, + Feb => 2, + Mar => 3, + Apr => 4, + May => 5, + Jun => 6, + Jul => 7, + Aug => 8, + Sep => 9, + Oct => 10, + Nov => 11, + Dec => 12, + ); + +# Read headers +$/ = ''; +my $head = <>; +$head =~ s/\n\s+/ /g; +my @headers = split("\n", $head); + +# Parse headers +my @hops; +for (@headers) { + next unless /^(>?Received|Date):/; + my $time; + my $host; + my $from; + if (/^Date:\s+(.*)/) { + $host = "Date:"; + $time = $1; + $from = ""; + } else { + $host = "(unknown)"; + $host = $1 if /\sby\s+([a-z0-9\-_+.]+)\s/ && $1 ne "uid"; + $from = "(unknown)"; + $from = $1 if /\sfrom\s+([a-z0-9\-_+.]+(?:\s+[(].+?[)]))\s/; + $time = "(unknown)"; + $time = $1 if /;\s+(.+)$/; + $time =~ s/using.*//; + } + + my $epoch = str2time ($time); + + unshift @hops, { HOST => $host, FROM => $from, TIME => $epoch}; +} + +# Print output +print " Host Date received (local) Lag +Total lag\n"; +my $nr = 0; +my ($first, $prev); +for (@hops) { + my $host = $_->{HOST}; + my $from = $_->{FROM}; + my $time = $_->{TIME}; + $first = $prev = $time unless defined $first; + printf "%2d. %-31.31s", ++$nr, $host; + do { print "\n"; next } unless defined $time; + + my $delta = $time - $prev; + my $neg = $delta < 0; $delta = abs($delta); + my $delta_h = int($delta / 3600); + my $delta_m = int(($delta - $delta_h * 3600) / 60); + my $delta_s = ($delta - $delta_h * 3600 - $delta_m * 60); + + my ($sec,$min,$hour,$day,$mon,$year,undef,undef,$dst) = localtime($time); + + printf " %4d-%02d-%02d %02d:%02d:%02d %s%02d:%02d:%02d", + 1900+$year, $mon+1, $day, $hour, $min, $sec, + $neg ? '-' : ' ', $delta_h, $delta_m, $delta_s; + + $delta = $time - $first; + $neg = $delta < 0; $delta = abs($delta); + $delta_h = int($delta / 3600); + $delta_m = int(($delta - $delta_h * 3600) / 60); + $delta_s = ($delta - $delta_h * 3600 - $delta_m * 60); + printf " %s%02d:%02d:%02d\n", + $neg ? '-' : ' ', $delta_h, $delta_m, $delta_s; + print " from $from\n" if $verbose; + $prev = $time; +}