Filed under: Terminal Tips
Terminal Tip: Accessing built-in calendars
On Sunday, I posted about the built-in calendars found in /usr/share/calendar. These calendars include listings of events from around the world and for religions, e.g. calendar.history and calendar.christian. Today, I thought I'd share some ways to access those calendars from the command line.
On pretty much any version of Mac OS X, you can use the built-in calendar command to list the events of the day. The -f flag allows you to select which calendar you want to access. The calendar.world file references all the other English-language calendars.
% calendar -f /usr/share/calendar/calendar.world
Apr 13 Thomas Jefferson born, 1743
Apr 12 Confederate troops fire first shots of Civil War at Ft Sumter, 1861
Apr 12 Space Shuttle Columbia launched, 1981
Apr 12 Yuri Gagarin becomes the first man in space, 1961
Apr 13 Laotian New Year (3 days) in Laos
Apr 13 National Day in Chad
Apr 13 Songkron Day in Thailand
and so forth...
%
You can embed this command into your startup files like ~/.bashrc so the events of the day display whenever you open a new shell. Unfortunately, the calendar command does not seem to work properly on my Intel-based Mac Mini; Mike reports that it works just fine on his MacBook Pro. If your Intel Mac is balking at the calendar command, you can use grep as a workaround: grep `date +%m/%d` /usr/share/calendar/calendar.*

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
Dina said 6:21PM on 4-12-2007
Bad news: http://www.apple.com/hotnews/
Reply
sam said 6:31PM on 4-12-2007
I am using this with geektool since you posted the tip last week.
Here is what I am using:
grep `date +%m/%d` /usr/share/calendar/calendar.history
That will show what happened on whatever today is.
Cheers!
Reply
MurphyMac said 6:42PM on 4-12-2007
That's really cool.
Anyone know how to redirect the output from the cal command so it can be pasted into windowed apps without getting all askew??
Reply
mark.hilstad said 1:36AM on 4-13-2007
My favorite calendar command:
$ cal 9 1752
September 1752
S M Tu W Th F S
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Reply
Cranky McGuy said 5:12AM on 4-13-2007
You should note that the XCode toolset needs to be installed in order for calendar to work. Otherwise it gets cpp errors since cpp isn't installed.
Great tip, though. And I had no idea about the cal command. Thanks, Mark. Now I've added:
echo ""
cal
calendar -f /usr/share/calendar/calendar.usholiday
echo ""
to the bottom of my .bash_profile so I see the calendar and upcoming holiday every time I open a shell.
Reply
tk719 said 11:12AM on 4-13-2007
Hey we have Thai new year on 13-15 April too
Reply