When working in the terminal it's inconvenient navigating up to the systray to display the current calendar. Is there a command that will display a calendar from the terminal?
-
2`apropos` and `man` are your friends. When in doubt run `apropos calendar` and see – phuclv Mar 03 '17 at 16:50
-
1Huh, never knew about `apropos` until now, +1 – kalenpw Mar 11 '17 at 00:16
6 Answers
cal calendar command for terminal
You can use the cal command to display a calendar in Julian or Gregorian format. The format depends on your locale settings but can be toggled with parameters.
As the screen below shows the default calendar is the current month. You can use the parameter -A 2 to display the next two months or 2018 to display all months in that year:
Ubuntu versions after 20.04
After version 20.04 you may have to use
sudo apt update
sudo apt install ncal
Note the ncal package does include the cal command. Also note that ncal is available out of the box in earlier Ubuntu versions before 20.04 as well.
For example on Ubuntu 16.04 LTS ECM:
$ ncal
March 2022
Su 6 13 20 27
Mo 7 14 21 28
Tu 1 8 15 22 29
We 2 9 16 23 30
Th 3 10 17 24 31
Fr 4 11 18 25
Sa 5 12 19 26
- 99,709
- 34
- 237
- 401
-
2You can also display a specific month with, e.g. `cal 6 2017`. – Michael Hampton Mar 03 '17 at 18:50
-
1Beware that `cal` is somewhat simple-minded about interpreting its arguments. `cal 6 17` will display the calendar for June ***of the year 17*** (i.e., 2000 years ago), and `cal 6` will display the calendar for the year 6. – G-Man Says 'Reinstate Monica' Mar 04 '17 at 20:16
-
2@G-Man `cal` is super-sophisticated. For example when in Canada, America or UK type `cal 9 1752` and you will see **September 1752** is missing the ten days Pope Gregory XIII annulled for the Western Catholic world in **October 1582**. People in Italy and possibly Germany and Sweden using `cal 10 1582` will see that calendar is missing the ten days. `cal` works up to the year 9,999 and I've tested February 2100 isn't a leap month and February 2400 is a leap month so it seems as future proof as it is historically accurate. – WinEunuuchs2Unix Mar 04 '17 at 20:35
-
Looks like `-A` is depreciated? In `cal` from `util-linux 2.32` that option isn't listed in the manual. You can instead use `cal -3` to display three months (one before, current, one after). – Mike Pierce May 25 '18 at 17:06
-
@MikePierce I tested in Ubuntu 18.04. `cal -3` does display one month before, current and one month after. However you can still use `cal -A3 -B2` to display 2 months before, current month and 3 months after. – WinEunuuchs2Unix Jun 03 '18 at 07:09
-
Not apparently included as part of a default Ubuntu install (21.10 for example). What package is it in? – Pointy Mar 10 '22 at 19:04
-
@Pointy `sudo apt install ncal` should solve that according to [these instructions](https://www.linuxfordevices.com/tutorials/linux/cal-command) – WinEunuuchs2Unix Mar 11 '22 at 00:06
-
@WinEunuuchs2Unix yea literally 5 minutes ago I stumbled on that, thank you very much! – Pointy Mar 11 '22 at 02:23
An alternative is ncal - this displays the calendar in a vertical format, i.e.:
March 2017
Su 5 12 19 26
Mo 6 13 20 27
Tu 7 14 21 28
We 1 8 15 22 29
Th 2 9 16 23 30
Fr 3 10 17 24 31
Sa 4 11 18 25
This is slightly harder to read, but supposedly has the advantage that the full year's calendar, by putting four months in each row, fits in a standard sized terminal. In fact, it does not, you have to remove blank lines from the output for it to fit in 24 lines: ncal 2017 | grep -v '^$'. The original version of ncal did not have these blank lines. In any case, it takes less vertical space than the traditional calendar output - 26×76, vs 35×66 for cal.
- 1,155
- 8
- 16
Khal is a calendar application that's much more along the lines of what someone might expect in the year 2020:
It can be installed via pip3 install khal (or just pip instead of pip3). It supports a standard CalDav format and can by synced to a CalDav server. Additionally it includes an interactive tool (ikhal or khal interactive) (sort of like tig for git) for viewing and editing events in an easier way without having to remember all the flags and syntax and everything.
- 99,709
- 34
- 237
- 401
- 241
- 2
- 5
-
1I hope you don't mind I took the liberty of adding an image so people can see what they will be getting. – WinEunuuchs2Unix Jul 29 '20 at 11:55
-
Programmable Calendars
Although these are GUI calendars you can still call them from the terminal. They allow you to navigate through the months and years. They are designed to be called from your Bash scripts but like all Bash commands you can call them from the terminal too.
YAD (Yet Another Dialog) super-charged fork of Zenity
Zenity GUI fork of text-based dialog
Do not be concerned by the Gtk warning message. You see that a lot when running GUI programs from the terminal. eg. gedit and nautilus display similar warnings.
- 99,709
- 34
- 237
- 401
Another alternative to the standard cal is an enhanced cal by Alex Matulich. It offers user-configurable colors and the ability to display reminders and appointments next to the calendar.
Enhanced cal page on Unicorn Research site
Edit 2022-06-01: It's available in the repos with sudo apt install ccal.
- 1,067
- 1
- 8
- 21
- 121
- 2
-
1+1 for your cool `$PS` that shows the current directory in reverse background color. Do you have a link for doing that? – WinEunuuchs2Unix Oct 06 '19 at 14:18
-
@WinEunuuchs2Unix Thanks! you can follow the instructions of this gist : https://gist.github.com/renshuki/3cf3de6e7f00fa7e744a – Sabrina Oct 07 '19 at 08:18




