Skip to content

Instantly share code, notes, and snippets.

@benmaughan
Created April 18, 2016 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmaughan/9d99d3810f5edf682a92ceb347119386 to your computer and use it in GitHub Desktop.
Save benmaughan/9d99d3810f5edf682a92ceb347119386 to your computer and use it in GitHub Desktop.
Count number of emails in inbox, drafts and outbox for mail indexed with mu and sent with sendmail or equivalent
#!/usr/bin/perl -w
###########################################################################
#
# Count number of emails in inbox, drafts and outbox for mail indexed
# with mu and sent with sendmail or equivalent
#
# by Ben Maughan
# http://www.pragmaticemacs.com
#
# Feel free to distribute, modify, whatever
#
###########################################################################
## total mails in inbox
chomp(my @tot=`/opt/local/bin/mu find maildir:/INBOX`);
## unread mails in inbox
chomp(my @unread=`/opt/local/bin/mu find maildir:/INBOX AND flag:unread`);
## drafts (implies delayed if using mu4e-delay)
chomp(my @drafts=`/opt/local/bin/mu find maildir:/[Gmail].Drafts`);
## number in outbox
chomp(my @mailq=`/usr/bin/mailq`);
my @outbox = grep /^[0-9A-F]{12}/, @mailq;
printf "@ %d/%d/%d/%d",$#unread+1,$#tot+1,$#drafts+1,$#outbox+1;
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment