prognos.is

Randomized mutt sigs

Randomized mutt sigs

It’s a bit ridiculous how much time I spent rebooting my blog back in 2014 and then barely posted any content since. This morning I was thinking, what would be a topic that might help someone out but which I could hammer out in a couple of minutes. Herewith…

I wanted to throw random funny quotes into my email sigs. Here’s how I set this up.

First stop, creating a custom fortune db:

  • Create a home for our fortune db: mkdir ~/.fortune
  • Define our pool of random quotes: $EDITOR ~/.fortune/quotes

    • Note that fortunes are delimited by %, a la:
      "This is a funny quote."
      %
      "This is actually another quote."
      
  • Do some magic for fortune: strfile ~/.fortune/quotes ~/.fortune/quotes.dat

    • Note that you’ll have to rerun this command each time you modify ~/.fortune/quotes.

Next, we need to glue a few bits together for mutt:

  • I didn’t want my entire sig to be randomized - just the quote bit. So I created a little bash script. Let’s call it ~/bin/work_sig.sh:

    #!/bin/bash
    
    cat ~/.mail/signatures/work
    echo '--'
    fortune ~/.fortune/quotes
    
  • I have different signatures defined for different accounts, so there are variations on this theme, a la ~/bin/personal_sig.sh:

    #!/bin/bash
    
    cat ~/.mail/signatures/personal
    echo '--'
    fortune ~/.fortune/quotes
    
  • You get the idea…

  • The last bit is telling mutt what to do. My mutt configuration is modular, with most things living in ~/.mutt/common and account-specific mutt configs. So, for personal, I’ve got something like this:

    source ~/.mutt/common
    set signature = "~/bin/personal_sig.sh|"
    
  • …and for work, something like this:

    source ~/.mutt/common
    set signature = "~/bin/work_sig.sh|"
    
  • This post is strictly focused on randomizing email sigs in mutt. I’ve elided a great deal about my email setup which wasn’t directly pertinent to the topic. Another day I’ll do a longer post describing my mail setup in detail.