MacOS – Displaying calendar events as text, in the terminal

calendarcommand linemacmacosterminal

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.

Best Answer

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).