A Kermit script to remind you of upcoming events
Author: Frank da Cruz
Script version: 1.02
Dated: 2020/01/11
|
|
Platform: Any platform where C-Kermit is available.
Requires:
C-Kermit 9.0.304 Dev.06 or later
This page last updated:
Sat Jan 11 19:50:09 2020
|
Columbia University has run central Unix timesharing systems since the mid-1980s. In
1990 the Systems Group wrote a C Program called remind that users
could invoke from their shell profile, to remind them of upcoming meetings,
appointments, birthdays, etc. Lots of people came to depend on it.
At the end of 2015, our central Unix servers were switched from 32-bit Sun
Solaris 9 (2003) to Red Hat Enterprise Linux 6.6 on x86-64, but the
original Remind program could not be built on the new platform because the
C language itself had changed beyond recognition since 1990.
So I wrote a replacement in the Kermit language, which is well suited for
the job because of its intrinsic ability to deal with dates. The resulting
program has about 100 lines of code compared to 3000 in the original...
and does more too.
Installation
C-Kermit 9.0.304 Dev.06 or later must be installed on your computer in order
to be able to run this script;
CLICK HERE if you
need to download and install it.
Assuming you have C-Kermit installed, then just
use the
getkermitscript to download the
remind script to the desired directory, which should be in your PATH
so you can run it. Optionally also
download the help
text file, which should be installed in the same directory. You can
also download the script by clicking
HERE, but then
you'll need to edit the "kerbang" line and give it execute permission, as
explained in the
getkermitscript page.
The .remind file
This is like the other ”dot-files” in your login directory:
the associated applications read them automatically when they start. So
when you run 'remind' (either directly, or from your shell profile, or any
other way), it reads and processes your
~/.remind file. A typical
.remind file looks like this (blank lines are ignored, and so are
comment lines (which begin with '
#' or '
;'):
# This is a comment
; This is also a comment
monthday 1 Turn the page on the wall calendar
monthday 1 Pay rent
weekday Wednesday 3:00pm weekly meeting
weekday sun Why are you using the computer?
fuzz 40
date 12-Jan-2020 2:30pm Dentist
date 14-Jan-2020 Mom's birthday
fuzz 300
date 29-Dec-2020 Server cutover
date 31-Mar-2020 Deadline to renew domains at Directnic
date 5-jun-2020 Donate blood 2:00pm 52nd Precinct
countdown 15-jun-2020 SOMEBODY's birthday
The result of running
remind on this file on Saturday,
January 11, 2020, selects and displays the following reminders:
---------------------------------
TOMORROW 12-Jan-2020: 2:30pm Dentist
Tuesday 14-Jan-2020: Mom's birthday
Tuesday 31-Mar-2020: Deadline to renew domains at Directnic
Friday 05-Jun-2020: Donate blood 2:00pm 52nd Precinct
Monday 15-Jun-2020: SOMEBODY's birthday (today +156d)
---------------------------------
With “
setlocale es_ES.ISO8859-1” the result is:
---------------------------------
Every domingo: Why are you using the computer?
TODAY 17-ene-2020: Document the Remind script
viernes 22-ene-2020: 2:30pm Dentist
---------------------------------
The Spanish words ("domingo" for Sunday; "ene" for
enero, which
is January) come out automatically from C-Kermit's date functions,
the others are from the script or the
~/.remind file.
The .remind file directives are:
- monthday
- Syntax: monthday n text
The given text is displayed on the nth day of every month,
where n is a number between 1 and 31.
- weekday
- Syntax: weekday dayname text
The given text is displayed on the given day of the week (spelled out in
full), for example every Wednesday, or if that doesn't work (depending on
limitations of your computer's operating system), the first three letters of
the day, e.g. Wed.
- date
- Syntax: date dd-mmm-yyyy text
The given text is displayed on or before the given date. Historically the
date had to be in dd-mmm-yyyy format, where mmm are the first three letters
of the English month name. The new remind scripts accepts other
formats too, as long as they don't contain any spaces, but if month names
are spelled out (abbreviated or in full), they must be in English (for now).
- countdown
- Syntax: countdown dd-mmm-yyyy text
Like "date" but also prints the number of days until the event occurs,
e.g. "(today +21d)", meaning 21 days from today.
- fuzz
- Syntax: fuzz n
Events for specific dates are shown as long as the date is not more than
n days in the future. By default, the fuzz factor is 365.
Running the remind script
Typically you would create a
.remind file in your login directory,
and then you would edit your shell profile (e.g.
.profile or
.bash_profile), adding a line that just says "remind". Assuming the
remind script is stored in a directory in your PATH and has execute
permission, you can also type "remind" at the shell prompt any time you want
to see reminders. Then over time, you can edit your
.remind file
whenever there are new events you want to be reminded of. You don't have to
remove old ones, they are automatically skipped by the script.
About the script
The script was designed to handle all existing
.remind files.
Results of running it can vary according to the underlying date and locale
functions of the operating system (
read about
locales). For example, some OS's might only
know 3-letter day names, in which case you must use 3-letter English
day names in any 'weekday' directives. It might help to set a specific
locale by giving commands such as these at the shell prompt:
LC_ALL=en_US.ISO8859-1
export LC_ALL
The most interesting thing about the remind script its use of
C-Kermit's built-in functions for handling
dates:
- \fdayname()
- Returns the name of the day of the week for a given date. By default
the result is in English but it can also be in other languages depending
on your Locale.
- \fcompdates()
- Compares two dates and tells whether the first one is later than,
the same as, or before the second one.
- \fcvtdate()
- Converts the given date into a given format. In this case we convert
"human"-style date into a sortable date so the list of events can be easily
sorted into chronological order internally before display in human-readable
format.
In all Kermit's date-handling functions, a wide variety of date (and time)
formats can be recognized. Read more about them
HERE.