Using Yosemite, is there a way to display events from my calendar in the command line?

I'm aware of the stock calendars apple supplies for things like holidays and such, /usr/share/calendar/ and the command 'calendar' to display events listed in these. Is there a way to do the same thing but list events from my own calendars?

I've found that personal calendars are stored in ~/Library/Calendars but everything I've found within that folder does not work with the 'calendar' command. There are several folders with ambiguous names similar to "D4385-GS57-D352-GA248592.calendar". And some folders contain a lot of *.ics files, which I think are calendar events.

  • calendar doesn't work with *.ics files, see man calendar for the supported file format. But I'm curious whether there are some other means to list the content of your calendar in a readable form. – nohillside Dec 16 '14 at 16:14
  • @patrix That's right. I read through the man page when I found out about this command. I don't know too much about how the calendars work in modern OS X, but I think the *.ics files are calendar entries. What you mentioned is what I'm looking for, some other means to list the calendar contents in text form. – mindheavy Dec 16 '14 at 16:19
up vote 7 down vote accepted

How about something like that:

$ find ~/Library/Calendars -name "*.ics" |
      xargs grep -h -e "SUMMARY" -e "DTSTAMP" |
      sed -E 's/^[A-Z].*:(.*$)/\1/g' |
      sed -E 's/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2}).*$/\1-\2-\3 \4:\5:\6/g'
Fist’s Birthday
2014-05-16 05:44:20
Secon’s Birthday
2014-07-26 09:58:49
Third’s Birthday
2014-05-16 05:44:20
...

This command will output all events in all your calendars (included subscribed ones).

  • 1
    This is great, I'm working through a sed beginners guide right now to learn how this works. I hope to learn enough to filter events by date. Ideally I would like to be able to pass a command that shows events for the current day and maybe five days out. – mindheavy Dec 18 '14 at 13:33

You should look into icalbuddy http://hasseg.org/icalBuddy/ . This lets you configure what days you want to output, by date/calendar and all fields. It actually interacts great with calendars of all kinds (synced and not) and can be used in terminal, geektool, etc.

I like to use Homebrew to install a version of icalbuddy that works fine with OS X 10.11

brew install ical-buddy 
  • Homebrew version can now be found at: brew install ical-buddy. Note the dash. – Richard Kranendonk Nov 1 '15 at 10:28

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.