Eric D. Schabell: Mutt hints - viewing iCal calendar invites

Monday, February 25, 2013

Mutt hints - viewing iCal calendar invites

This is not the first place this has been posted but I wanted to capture it for myself here. I am not attempting to auto import ical files, or your meeting invites, into my macbook calendar application. I just want to view the details inline of the meeting.

Add this ruby script to your path:

#!/usr/bin/env ruby

require "rubygems" # apt-get install rubygems
require "icalendar" # gem install icalendar
require "date"

class DateTime
  def myformat
    (self.offset == 0 ? (DateTime.parse(self.strftime("%a %b %d %Y, %H:%M ") + self.icalendar_tzid)) : self).
        new_offset(Rational( - 60*60, 24*60*60)).strftime("%a %b %d %Y, %H:%M")
        # - 60*60 to compensate for icalendar gem/Outlook mismatch

cals = Icalendar.parse($<)
cals.each do |cal| do |event|
    puts "Organizer: #{event.organizer}"
    puts "Event:     #{event.summary}"
    puts "Starts:    #{event.dtstart.myformat} local time"
    puts "Ends:      #{event.dtend.myformat}"
    puts "Location:  #{event.location}"
    puts "Contact:   #{event.contacts}"
    puts "Description:\n#{event.description}"
    puts ""

Add this to your .mailcap file:

text/calendar; icalview.rb; copiousoutput

Then finally, add this to your .muttrc:

auto_view text/calendar

Enjoy viewing your meetings now!