You can do a lot of interesting and useful things from the command prompt in the Terminal app on the Apple Mac. Perhaps that is why many people like it. Here is how to access the calendar tool.
The Mac has a useful Calendar app that has many great features, but when you are working at the command prompt and need to quickly look up a date, it may be quicker and easier to simply use the command line calendar tool. You don’t have to reach for the mouse and click buttons to see dates.
There is a built-in cal command that can show calendars in the command prompt window. Even if you don’t use command line tools on your Mac, you might like to try this just for fun or out of interest. It’s like discovering a hidden tool or capability you didn’t know your Mac had.
Show this month’s calendar with cal
Press Command+spacebar, type ‘terminal’ and hit Enter to open the Terminal app and access the command prompt.
There are actually two calendar tools, one called cal and the other called ncal. Enter them both to see the difference between them. Both display the current month with today highlighted, but cal shows the days horizontally and cal shows them vertically. Use whichever you prefer. I will continue with cal, but substitute ncal if you prefer it.
Show months before and after with cal
Entering cal on its own shows the current month. Suppose you want to show the next three months. You would enter ‘cal -A 2‘ which shows the current month And (-A) the next two (2) months. That is three in total. Use 1, 2, 3, 4 and so on to show as many months after as you need.
Use -B to show months Before the current month. For example, enter ‘cal -B 2‘ to show this month and the two months before it.
View a full year calendar with cal
Type cal followed by the year to display a full year’s calendar in the Terminal window. Enter ‘cal 2023‘ for this year, ‘cal 2024‘ for next year and so on.
Advanced calendar displays with cal
Suppose you only want to see one month of the year. In this case enter ‘cal month year‘, for example, enter ‘cal 4 2024‘ to see the fourth month of 2024, which is April of course.
A useful variation of this is ‘cal -3 4 2024‘. This time I added a -3 to the start of the command, which means show three months, centered around 4 (April) 2024. It shows March, April, and May.
The final example is ‘cal -A 5 4 2024‘ which looks complicated, but really it isn’t. Work backwards and 2024 is the year and 4 is the month. This will show April 2024. The -A 5 means show the 5 months after it too. So that’s six months in total, the specified month and the 5 after it.
By substituting -B for -A the months before will be displayed instead.
There are other ways this command can be used and if you enter something it can’t understand, it displays some help:
cal [general options] [-hjy] [[month] year]
cal [general options] [-hj] [-m month] [year]
ncal [general options] [-hJjpwy] [-s country_code] [[month] year]
ncal [general options] [-hJeo] [year]
General options: [-NC3] [-A months] [-B months]
For more information on these command line switches, enter ‘man cal‘ at the command prompt.