Cal – Display a Calendar in Your Terminal
adriansieber.com
adriansieber.com
~ $ 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 31Usability helps with being correct
Vast majority of uses of cal apply to dates > 1900 (and I'd say a significant amount is > 2000)
'cal 16' should require a flag saying "Yes, I know what I'm doing, this is the actual year" and/or print the corresponding year for this century (being explicit, when printing, to which year it refers to)
According to what? Your use?
> 'cal 16' should require a flag saying "Yes, I know what I'm doing, this is the actual year" and/or print the corresponding year for this century (being explicit, when printing, to which year it refers to)
The command wants a year number as input. '16 is an ambiguous abbreviation that gains meaning only within context. As the command can't ask you what you meant, the default behaviour is sane.
Without an explicit flag that should be used in a script, the dwim behavior (2016) seems more appropriate for the interactive use.
Do you know anyone or any use case that requires calculations of years between 0-99 and uses cal?
Yes, it is quite obvious that most uses is for years > 1900, you're free to do a study yourself if that's what you want.
> As the command can't ask you what you meant, the default behaviour is sane.
Not from an usability point of view.
cal: year `10000' not in range 1..9999I've used it myself in scripts to find Julian day numbers, to count days-within-months, etc. -- for old science data -- before there were more robust ways to do this stuff.
It's hard to insert DWIM behaviors into old command-line utilities, because "what I mean" is not clear.
Call me old-fashioned but I like keyboards (still)?
Pretty sure my thought process was: need a Thanksgiving flight -> when is Thanksgiving this year? -> run cal(1) -> let's book.
$ 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
[...] $ 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 30Part 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.
~$ 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[1] https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reck...
I don't think the 5th edition had cal.
$ 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.
[...] 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 $ 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 30The program produced TeX output so I could print a nice wall calendar (complete with tasks and birthdays).
Was kind of klunky, but it worked.
Try:
cal -m
I even have it aliased to "calm" :-) ncal -M [year]* http://anonscm.debian.org/cgit/bsdmainutils/bsdmainutils.git...
* http://anonscm.debian.org/cgit/bsdmainutils/bsdmainutils.git...
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.
I think ISO chose it because there was considerable difference between countries as to what the first day of the week in usual calendar presentation was when ISO 8601 was being considered, they needed something consistent, and it just happened to shake out to Monday.
Because ISO is all about business, and Monday is the start of the business/banking etc week.
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 weekend, 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.
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.
cal: option requires an argument -- m
usage: cal [-jy] [[month] year]
cal [-j] [-m month] [year]
ncal [-Jjpwy] [-s country_code] [[month] year]
ncal [-Jeo] [year] 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 -hEnclose 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'.
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.
https://en.wikipedia.org/wiki/Util-linux
read all the pages, explore all the man pages, then experiment and learn.
or go to the source: https://github.com/karelzak/util-linux