▲ 160 points
back
92 comments
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 31I lost a hundred bucks to this behavior.
If you need a month in the current year, or the entire current year, that's easy:
$ cal may
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
$ cal -y
2016
January February March
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 1 2 3 4 5
3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12
10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19
17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26
24 25 26 27 28 29 30 28 29 27 28 29 30 31
31
[...]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.
Well, it's displaying the calendar for May of the year 16, not the year 2016. I guess it could require you to enter 0016, but I think the given behavior is reasonable.
...said nobody before the Y2K bug...
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 30wttr doesn't seem to like putty+windows very much: http://i.imgur.com/45KSLFx.png
wttr.in looks awesome! I'm not going to complain about it, but it is a little funny that shows a big yellow sun under "Night".
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 30A nice explanation here: https://unix.stackexchange.com/questions/17903/is-cal-broken...
That feature already was in 6th edition UNIX, in 1975: http://man.cat-v.org/unix-6th/6/cal.
I don't think the 5th edition had cal.
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.
[...]Geez, I had no idea about `calendar`. This is pretty nifty!
Cool, good to know! Maybe I'll write a future command line monday post about this. Sounds really helpful!
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 29That is insane. The case-insensitive filesystem means the same binary runs, but the binary has a switch on the case of its own name.
AKA ncal.
I love this original responsive and flat UI calendar and use it all the time.
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!
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).
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 30I 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.
also noteworthy: khal [0], a CLI calendar program which syncs to CalDAV servers with vdirsyncer [1].
No GoT joke on khal Github!
I use 'cal' on a daily basis. I don't find any other calendar programs to be as convenient and simple to use.
I love cal, but M-x calendar is pretty awesome too.
"cal" is the only calendar on my OS, who needs that other bloat.
Try:
cal -m
I even have it aliased to "calm" :-)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?
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.
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.
iStat Menus can add a calendar under the clock.
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 -hNote 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'.
You can check out the follow up post at http://adriansieber.com/fold-wrap-lines-to-fit-in-specified-... =)
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.
I always learn about these stuff, think about using them all the time, then I totally forget until someone posts it again on HN.
no mention of "cal -y" which should have been the default most common use option IMHO.
if you really want to go nuts -
https://en.wikipedia.org/wiki/Util-linux
read all the pages, explore all the man pages, then experiment and learn.
I use cal almost every day. Way faster than phone or web page calendars.
Wow. Had no idea that existed. Looking forward to more tidbits
take a walk through /usr/share/doc
or go to the source: https://github.com/karelzak/util-linux
ncal is an interesting take on a calendar
gcal -n --astronomical-holidays
Just updated the post and added this as another useful flag =)