Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Created December 23, 2014 23:56
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 pdxmph/cfc4dd675184c06e405e to your computer and use it in GitHub Desktop.
Save pdxmph/cfc4dd675184c06e405e to your computer and use it in GitHub Desktop.
Some handy mutt macros for this and that

Implement Lightweight Profiles to switch between email personae

Setup: Make personal.profile and work.profile files and use them to configure the things that are unique to each identity, e.g.

	# -*- muttrc -*-                                                                                                                                         
	# Mutt sender profile : personal/default                                                                                                                 

	# get us out of whatever default folder we're in																																																																								 
	unset folder

	# reset us to the right folder and mailboxes for this persona                                                                                                                                            
	set folder = ~/.mail/personal                                                                                                                            
	set spoolfile = +INBOX                                                                                                                                   
	unmailboxes *                                                                                                                                            
	mailboxes +INBOX +flagged +sent +To\ Ben                                                                                                                 

	# customize to suit for this persona																																																																												 
	set hostname="puddingbowl.org"                                                                                                                           
	set signature= "~/.mutt/personal.sig"                                                                                                                    
	set from=mph@puddingbowl.org                                                                                                                             
	set realname = "Mike Hall"                                                                                                                               
	set smtp_url = "smtp://pdxmph@smtp.gmail.com:587/"                                                                                                       
																																																																							 
	# set the status to show which profile we're using                                                                                                         
	set status_format= "-%r-Personal: %f [Msgs:%?M?%M/?%m%?n? New:%n?%?o? Old:%o?%?d? Del:%d?%?F? Flag:%F?%?t? Tag:%t?%?p? Post:%p?%?b? Inc:%b?%?l?          
	%l?]---(%s/%S)-%>-(%P)---\n"                                                                                                                             
																																																																							 
	# z out our headers and make the right ones for this persona
	unmy_hdr *                                                                                                                                               
																																																																							 
	my_hdr From: Michael Hall <mph@puddingbowl.org>                                                                                                          
	my_hdr Organization: puddingbowl.org                                                                                                                     
	my_hdr Sender: Michael Hall <mph@puddingbowl.org>                                                                                                        
	my_hdr Return-Path: <mph@puddingbowl.org>                                                                                                                

	# Set the right macros to sync the account via offlineimap so that when we do a sync, we're only syncing the
	# current active persona
																																																																			 
	macro index O "<shell-escape>offlineimap -a personal -q -uquiet<enter>"           "run offlineimap to sync all mail"                                     
	macro index o "<shell-escape>offlineimap -a personal -qf INBOX -uquiet<enter>" "run offlineimap to sync inbox"         

Then use these macros:

<c>hange to <p>ersonal

	macro index .cp '<enter-command>source ~/.mutt/personal.profile<enter><change-folder>=INBOX/<enter>'

<c>hange to <w>ork

	macro index .cw '<enter-command>source ~/.mutt/puppet.profile<enter><change-folder>=INBOX/<enter>'

Reload configurations if you make a tweak without having to restart mutt

	macro index,browser .r "<enter-command>source ~/.muttrc<enter>"

Limit the messages you can see to certain criteria:

	macro index .so "l ^a^k^O\n 				# show old messages only
	macro index .sn "l ^a^k~N\n" 				# show unread/new only
	macro index .sf "l ~F\n" 						# show flagged messages only
	macro index .si "l (~n5-100|~N)\n" 	# show higher scoring messages 
	macro index .hl "l ^a^k!~l\n" 			# hide list messages

Then reveal all your messages again:

	macro index .sa "l ^a^kall\n" 			# show all messages

Tag old messages for quick disposition:

	macro index .to "T ~d>7d\n" # "tag old" -- messages older than 7 days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment