
Cal – Display a Calendar in Your Terminal - adius
http://adriansieber.com/cal-display-calendar-in-terminal/
======
cbr
Just don't try to use two digit format for years:

    
    
        ~ $ cal 5 16
               May 16
        Su Mo Tu We Th Fr Sa
                        1  2
         3  4  5  6  7  8  9
        10 11 12 13 14 15 16
        17 18 19 20 21 22 23
        24 25 26 27 28 29 30
        31
        ~ $ cal 5 2016
              May 2016
        Su Mo Tu We Th Fr Sa
         1  2  3  4  5  6  7
         8  9 10 11 12 13 14
        15 16 17 18 19 20 21
        22 23 24 25 26 27 28
        29 30 31

~~~
sigil
I lost a hundred bucks to this behavior.

[http://alangrow.com/blog/how-i-lost-100-and-blamed-
cal](http://alangrow.com/blog/how-i-lost-100-and-blamed-cal)

~~~
codezero
How did you not notice calendar on the flight booking site? I've never used
one that took a date string without showing a clickable calendar.

~~~
sigil
This was aa.com circa 2008, back when datepicker widgets were the hot new
thing and calendars in popup windows ruled the earth.

Call me old-fashioned but I like keyboards (still)?

~~~
codezero
archive.org shows a date picker going back as far as 2002, but it is easy to
pick a date from the drop down.

~~~
sigil
The dropdown doesn't help you with "fourth Thursday in November" though, and
the calendar button launches a popup window that doesn't work. On archive.org
at least -- may have worked at the time, but I disable popups, so...

Pretty sure my thought process was: need a Thanksgiving flight -> when is
Thanksgiving this year? -> run cal(1) -> let's book.

------
wyc
Another useful command line service I use almost daily (using a rather wide
terminal):

    
    
      $ curl wttr.in/94035
    

My most frequently used option for cal on GNU/Linux is "-3". It shows the
current, previous, and next month with the current day highlighted, which are
usually all the information I need.

    
    
      $ cal -3
    
             April 2016             May 2016              June 2016  
        Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
    
                        1  2   1  2  3  4  5  6  7            1  2  3  4
    
         3  4  5  6  7  8  9   8  9 10 11 12 13 14   5  6  7  8  9 10 11
    
        10 11 12 13 14 15 16  15 16 17 18 19 20 21  12 13 14 15 16 17 18
    
        17 18 19 20 21 22 23  22 23 24 25 26 27 28  19 20 21 22 23 24 25
    
        24 25 26 27 28 29 30  29 30 31              26 27 28 29 30

~~~
sbierwagen
wttr doesn't seem to like putty+windows very much:
[http://i.imgur.com/45KSLFx.png](http://i.imgur.com/45KSLFx.png)

~~~
janvdberg
This has to do with your character set. See Window->Translation->Remote char
set. Change it to UTF-8 or the one that is on your system.

~~~
sbierwagen
It _was_ in UTF-8.

Part of the problem seems to be GNU Screen-- if I switch tabs, then switch
back, the redraw seems to clobber some formatting characters.

EDIT: LC_CTYPE wasn't set for that user, but setting it didn't fix anything.
So, who knows.

------
JoshTriplett
A really fun detail in cal:

    
    
        ~$ cal 9 1752
           September 1752
        Su Mo Tu We Th Fr Sa
               1  2 14 15 16
        17 18 19 20 21 22 23
        24 25 26 27 28 29 30

~~~
jaybosamiya
A nice explanation here: [https://unix.stackexchange.com/questions/17903/is-
cal-broken...](https://unix.stackexchange.com/questions/17903/is-cal-broken-
what-happened-in-september-1752)

~~~
ashmud
A bit of trivia [1] linked from that discussion about Julian calendar still in
use.

[1]
[https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reck...](https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reckoning)

------
ams6110
FTA: _I’d be really excited to hear all the use cases for gcal one can come up
with. Seems really suited for a TODO list manager or to never forget a
birthday again._

    
    
      $ man calendar
      CALENDAR(1)                 General Commands Manual                CALENDAR(1)
    
      NAME
         calendar - reminder service
    
      SYNOPSIS
         calendar [-abw] [-A num] [-B num] [-f calendarfile] [-t [[[cc]yy]mm]dd]
    
      DESCRIPTION
         The calendar utility checks the current directory or the directory
         specified by the CALENDAR_DIR environment variable for a file named
         calendar and displays lines that begin with either today's date or
         tomorrow's.  On Fridays, events on Friday through Monday are displayed.
    
      [...]

~~~
skeoh
Geez, I had no idea about `calendar`. This is pretty nifty!

------
mcphage
On OSX at least, if you run it as CAL instead of cal you get a sideways
calendar:

    
    
        mcphage:~ $ CAL
            May 2016
        Mo     2  9 16 23 30
        Tu     3 10 17 24 31
        We     4 11 18 25
        Th     5 12 19 26
        Fr     6 13 20 27
        Sa     7 14 21 28
        Su  1  8 15 22 29

~~~
inyourtenement
That is insane. The case-insensitive filesystem means the same binary runs,
but the binary has a switch on the case of its own name.

~~~
mcphage
A lot of apps pay attention to the name you run them as—for instance, making
sure the correct name is reported when you list the command line switches. But
this is definitely the most extreme case I'm aware of.

------
geodel
I love this original responsive and flat UI calendar and use it all the time.

------
snorkel
Good ol cal! Circa 1998 my first homebrew web ui date picker input was just
cal output redressed with html links ... And we were thankful for what we had!

------
geofft
Huh, despite being the "GNU" calendar program, gcal is in fact generally named
gcal on GNU/Linux. On my Debian GNU/Linux machine, /usr/bin/cal is from
bsdmainutils, and gcal is in its own package (as with Homebrew).

------
res0nat0r
gcal highlighting the current date and '.' are nice features for me.

    
    
        $ brew info gcal
        gcal: stable 4 (bottled)
        Program for calculating and printing calendars
        https://www.gnu.org/software/gcal/
        /usr/local/Cellar/gcal/4 (81 files, 2.8M) *
          Poured from bottle on 2016-01-13 at 17:03:09
        From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gcal.rb
        ==> Dependencies
        Build: xz
    
                                           2016
    
    
                April                      May                       June
          Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa      Su Mo Tu We Th Fr Sa
                          1  2       1  2  3  4  5  6  7                1  2  3  4
           3  4  5  6  7  8  9       8  9 10<11>12 13 14       5  6  7  8  9 10 11
          10 11 12 13 14 15 16      15 16 17 18 19 20 21      12 13 14 15 16 17 18
          17 18 19 20 21 22 23      22 23 24 25 26 27 28      19 20 21 22 23 24 25
          24 25 26 27 28 29 30      29 30 31                  26 27 28 29 30

------
gerbilly
I once used cal as input to another program in the old days when there weren't
many calendar APIs in C yet.

The program produced TeX output so I could print a nice wall calendar
(complete with tasks and birthdays).

Was kind of klunky, but it worked.

------
sasvari
also noteworthy: khal [0], a CLI calendar program which syncs to CalDAV
servers with vdirsyncer [1].

[0] [https://github.com/pimutils/khal](https://github.com/pimutils/khal)

[1]
[https://github.com/pimutils/vdirsyncer](https://github.com/pimutils/vdirsyncer)

~~~
LaurentGh
No GoT joke on khal Github!

------
sgt
I use 'cal' on a daily basis. I don't find any other calendar programs to be
as convenient and simple to use.

~~~
zeveb
I love cal, but M-x calendar is pretty awesome too.

~~~
quanticle
M-x calendar is my go-to cal substitute on platforms that lack cal ( _cough_
Windows _cough_ ). Though, now that Windows 10 has a Linux subsystem, I might
just use cal everywhere.

------
towb
"cal" is the only calendar on my OS, who needs that other bloat.

Try:

    
    
      cal -m
    

I even have it aliased to "calm" :-)

~~~
looki
The output is the same as just "cal" for me, so I had to see what it's about:
It puts Monday as the first day of the week. I guess that is because I use the
German date locale. Seems that the US uses Sunday as the first day of the week
in calendars and such, but does it make any difference beyond those? Don't
people "feel" that Monday is the first day of the week because the weekend is
over and they have to get back to work?

~~~
zeveb
> Don't people "feel" that Monday is the first day of the week because the
> weekend is over and they have to get back to work?

No, I feel that Sunday is the day of rest I start my week with, then I do some
work, and finally I rest again: in that way my day is a microcosm of my week
(and one might think that in a more primitive society my year would be a
macrocosm, as I did more work spring-summer than during the winter).

I personally detest calendars which display Monday as the first day of the
week, and am genuinely curious why ISO chose that.

~~~
Symbiote
I personally detest calendars which display Sunday as the first day of the
week, since it's incorrect according to one of the earliest memories I have --
my mum teaching my this rhyme:

    
    
      Solomon Grundy,
      Born on a Monday,
      Christened on Tuesday,
      Married on Wednesday,
      Took ill on Thursday,
      Grew worse on Friday,
      Died on Saturday,
      Buried on Sunday,
      That was the end,
      Of Solomon Grundy.
    

Also, Saturday and Sunday are the week _end_ , not the week-edges.

\--

There's a bug in cal -- the man page says "-M" makes the week start on Monday,
but my version doesn't accepthe argument.

I find it quite confusing when calendars mess this up. I once booked a flight
on the wrong day, because I somehow switched to the American localization of
the airline's website part-way through the booking process.

~~~
ars
> Also, Saturday and Sunday are the weekend, not the week-edges.

You might be interested to know that in Israel the work week starts on Sunday,
not Monday. Friday and Saturday are the weekend.

That might just be a factoid, except that the Jewish Sabbath was the origin of
the weekend concept. It changed in countries with a strong Christian influence
so that Monday because the first day.

It never changed in the US because the Jewish workweek had a stronger
influence there than the Christian one.

> I personally detest calendars which display Sunday as the first day of the
> week

And I personally find calendars that start on Monday quite bizarre since it's
obviously incorrect historically.

------
adius
You can check out the follow up post at [http://adriansieber.com/fold-wrap-
lines-to-fit-in-specified-...](http://adriansieber.com/fold-wrap-lines-to-fit-
in-specified-width/) =)

------
bootload
love Cal, call a script to use it in my .bashrc to show current date, user,
day/time, logins and filesystem status.

    
    
        clear
        cal
        echo "Hey \033[1m$USER\033[0m it's \033[1m`date '+%A %d %B @ %T'`\033[0m" | 
              tr '[A-Z]' '[a-z]' 
        echo "logins:\c" ; who | wc -l
        df -h

~~~
emmelaich
Note that output from .bashrc stuffs up rsync and scp, in case you use them.

Enclose the lot in { .... } >&2

to send output to stderr instead.

Or only output if the session is interactive, with isatty or if PS1 is set or
$- contains 'i'.

~~~
bootload
_" Note that output from .bashrc stuffs up rsync and scp, in case you use
them. Enclose the lot in { .... } >&2"_

I call a shell script from my .bashrc so does this have the same effect? I'll
take this advice and wrap the script. I don't use scp or rsync but possible
could at some time, thanks @emmelaich.

------
oneeyedpigeon
cal is great, but I _never_ remember it exists. I always (OSX) go up to the
menubar datetime, get annoyed that there's no kind of simple calendar
underneath it (just wrap cal!), then go hunting for Google Calendar. I guess I
just don't think of that kind of program as a built-in command-line one.

~~~
hereonbusiness
I feel you, having used Linux (and I guess Windows) a lot longer than OSX this
gets me every time, and every time I wonder why such a simple and useful
feature was omitted.

------
ruggeri
Killer feature of gcal for me is that by default it highlights the current
day. Didn't know about `gcal .`, which is very convenient to know; I used to
do `gcal 2016` if I needed to see prev/next months.

------
eknkc
I always learn about these stuff, think about using them all the time, then I
totally forget until someone posts it again on HN.

------
jijojv
no mention of "cal -y" which should have been the default most common use
option IMHO.

------
MikeTLive
if you really want to go nuts -

[https://en.wikipedia.org/wiki/Util-linux](https://en.wikipedia.org/wiki/Util-
linux)

read all the pages, explore all the man pages, then experiment and learn.

------
ams6110
I use cal almost every day. Way faster than phone or web page calendars.

------
FajitaNachos
Wow. Had no idea that existed. Looking forward to more tidbits

~~~
MikeTLive
take a walk through /usr/share/doc

or go to the source: [https://github.com/karelzak/util-
linux](https://github.com/karelzak/util-linux)

------
Bushra8
gcal -n --astronomical-holidays

~~~
adius
Just updated the post and added this as another useful flag =)

