Working with calendars in the shell
calendar
With calendar
, which most distributions preinstall with the bsdmainutils package, you can output the current date's events in the terminal. If you set the command without further options, you will see a long list of mostly irrelevant information. You can restrict the query to the UK, for example, by calling calendar
with the -f
parameter and an appropriate event file, as shown in Figure 6. Such files can be found in /usr/share/calendar/en_UK/
on most distributions.
You can enter your own additional calendar data in your personal .calendar
file. For example, on Debian and Ubuntu, copy the /usr/share/calendar/en_UK/calender.all
file to $HOME/.calendar
. Below the #include
statements, enter your own anniversaries and events (in Listing 5, the entries for January 6 and 7). Each record begins with the month number, and you separate the following day with a slash. You use the tab key as a field separator between the date and the entry text.
Listing 5
Personal Calendar Entries
/* * UK Calendar */ #ifndef _en_UK_all_ #define _en_UK_all_ #include <en_UK/calendar.holiday> #include <en_UK/calendar.history> #include <en_UK/calendar.christian> #include <en_UK/calendar.literature> #include <en_UK/calendar.music> #include <en_UK/calendar.science> 01/06 Annivery of First ascent Blaabjerg north face 01/07 Birthday mother in law #endif /* !_de_DE_all_ */
Taking a brief look at the calendar.christian
file, you can see how calendar
calculates the dependent holidays based on Easter Sunday. This function can be used to create your own calendars.
Table 2 contains some important options for using the program. You can save the call along with your preferred options as an alias in the shell's personal or system-wide configuration file.
Table 2
calendar Options
Action |
Option |
Specify the configuration file |
|
Output the weekday |
|
Number of days to show (future) |
|
Number of days to show (past) |
|
Show specific day |
|
1 -l0 restricts output to today |
Figure 7 shows some examples, where all commands refer to the user's personal calendar file. If you do not specify your personal file, Calendar resorts to the system-wide variant.
Calendars with pcal
The pcal
program [6], which can be found in the repositories of all the popular distributions, creates a calendar in PostScript or HTML format. Because of the extensive options and the granularity of the calendar data, working with it seems complicated at first. The tool's most important options are summarized in Table 3. The program's man page could certainly be a tad more user-friendly.
Table 3
pcal Options
Action |
Option |
Example |
Specify calendar config file |
|
|
Select language |
|
|
European date format |
|
– |
Paper format |
|
|
Empties fields for days not in the month |
|
– |
First weekday |
|
|
Show moon phase daily |
|
– |
Show moon phases |
|
Full moon, half moon, new moon |
Font |
|
Helvetica, 12 point |
Output file |
|
– |
Calendar month |
|
– |
Calendar year |
|
– |
Annual calendar on one page |
|
– |
Color black for specified day |
|
Saturday ( |
Deviating color |
|
Red on light beige for Sundays and holidays: |
You store the configuration of the desired calendar in a separate file, named .pcal
in our example. In the file, you define a calendar year with its holidays. Listing 6 shows an example for Germany with special regional holidays for Bavaria.
Listing 6
Personal .pcal file
01 # Week number on Monday 02 all Monday in all week %w 03 04 Easter # +/- is computed relative to Easter 05 # * by date = holiday 06 Monday after Easter* Easter Monday 07 Good_Friday* Good Friday 08 49th day after Easter* Whit Sunday 09 50th day after Easter* Whit Monday 10 39th day after Easter* Ascension Day 11 60th day after Easter* Corpus Christi 12 # none * = not a holiday 13 48th day before Easter Shrove Monday 14 46th day before Easter Ash Wednesday 15 7th day before Easter Palm Sunday 16 17 01. 01.* New Year 18 06. 01.* Epiphany 19 01. 05.* Labor Day 20 08. 08.* Peace Festival (Augsburg) 21 15. 08.* Assumption 22 03. 10.* German Unification Day 23 01. 11.* All Hallows 24 24. 12. Christmas Eve 25 25. 12.* 1st Day of Christmas 26 26. 12.* Boxing Day 27 31. 12. New Year's Eve 28 29 sun on_or_before 24. 12. 4th Sunday in Advent 30 sun on_or_before 17.12. 3rd Sunday in Advent 31 sun on_or_before 10.12. 2nd Sunday in Advent 32 sun on_or_before 3.12. 1st Sunday in Advent
Some special rules apply here. There are different specifications for the specific day. With all <day>
, you designate a day for which you want special highlighting. Listing 6, line 1, displays the word "Week" and the consecutive week number every Monday. Line 17 shows New Year's Day as a public holiday. There must be a space between the day and month entries.
To display a day as a public holiday, add an asterisk (*
) followed by the desired text. Many holidays are a fixed number of days before or after Easter (see Listing 6, lines 4-15). Other holidays work like New Year's Day: You specify the holiday with a fixed date, including an asterisk if it's a public holiday.
Christmas can be complicated because December 24 can also be the fourth Sunday in Advent (e.g., in 2023). You need to use on_or_before
here. This allows December 24 to be the fourth Sunday in Advent if it happens to be on a Sunday. You can then define the dates of the remaining Sundays in Advent (see lines 29-32 of Listing 6).
Nonstandard characters can cause problems here. Modern distributions use UTF-8 encoding, but pcal
insists on ISO-8859-15.
By default, pcal
outputs Sundays and holidays in gray, which usually makes these days more prominent in black and white prints. You can create an overview calendar with Sundays and holidays printed in red and the moon phases, using the code in Listing 7. Figure 8 shows the results.
Listing 7
Annual Calendar
$ pcal -f .pcal -a en -E -P a4 \ -B -F 0 -M -g sun \ -s 1.0:0.0:0.0/1.0:1.0:0.8 \ -b sat -n Helvetica/10 -w \ -o Calendar.ps 2021
You can create a monthly calendar without the -w
option; instead, you specify the month before the year (Listing 8). The result is shown in Figure 9. You can process the resulting PostScript file to create a complete calendar page by adding a photo, for example, using Inkscape.
Listing 8
Monthly Calendar
$ pcal -f .pcal -a en -E -P a4 \ -B -F 0 -M -g sun \ -s 1.0:0.0:0.0/1.0:1.0:0.8 \ -b sat -n Helvetica/10 \ -o January-2021.ps 01 2021
Appointment Management
A small but good command-line program named calcurse
, which you will find in the repositories of all the popular distributions, lets you manage general tasks and tasks with deadlines. The simple interface is more or less self-explanatory. If you have worked with Nano before, you will get along with the menu control used in calcurse
right away. You can jump between the Appointments, Calendar, and To do fields by pressing the tab key; you use the arrow keys to reach targets in your appointments and calendar. Figure 10 shows the full screen.
To enter a new appointment, press A and enter the start time, the end time, and the description text (Figure 11). Pressing Enter saves the new appointment (Figure 12). Press Ctrl+T to create a new task (Figure 13). Start by entering the task text, then press Enter, and then set a priority. This affects the order in which tasks are displayed. Figure 14 shows the appointment and task entries.

Pressing O takes you to more commands and the settings. You can export the calendar entries in the ICAL or PCAL format or import data in these formats. If you call calcurse
with the -a
option, it displays all appointments for the current date on-screen (Figure 15).
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
OpenMandriva Lx 23.03 Rolling Release is Now Available
OpenMandriva "ROME" is the latest point update for the rolling release Linux distribution and offers the latest updates for a number of important applications and tools.
-
CarbonOS: A New Linux Distro with a Focus on User Experience
CarbonOS is a brand new, built-from-scratch Linux distribution that uses the Gnome desktop and has a special feature that makes it appealing to all types of users.
-
Kubuntu Focus Announces XE Gen 2 Linux Laptop
Another Kubuntu-based laptop has arrived to be your next ultra-portable powerhouse with a Linux heart.
-
MNT Seeks Financial Backing for New Seven-Inch Linux Laptop
MNT Pocket Reform is a tiny laptop that is modular, upgradable, recyclable, reusable, and ships with Debian Linux.
-
Ubuntu Flatpak Remix Adds Flatpak Support Preinstalled
If you're looking for a version of Ubuntu that includes Flatpak support out of the box, there's one clear option.
-
Gnome 44 Release Candidate Now Available
The Gnome 44 release candidate has officially arrived and adds a few changes into the mix.
-
Flathub Vying to Become the Standard Linux App Store
If the Flathub team has any say in the matter, their product will become the default tool for installing Linux apps in 2023.
-
Debian 12 to Ship with KDE Plasma 5.27
The Debian development team has shifted to the latest version of KDE for their testing branch.
-
Planet Computers Launches ARM-based Linux Desktop PCs
The firm that originally released a line of mobile keyboards has taken a different direction and has developed a new line of out-of-the-box mini Linux desktop computers.
-
Ubuntu No Longer Shipping with Flatpak
In a move that probably won’t come as a shock to many, Ubuntu and all of its official spins will no longer ship with Flatpak installed.