cal command - start monday
I was wondering - is there a way to make 'cal' (a terminal program) start the week on monday?
Usually it can be done with the -m flag, but this does not have any effect on the Mac. AFAIK, for freebsd you need deskutils, but I could not find any equivalent on the mac, even in homebrew.
Is there a switch or alternate source for a cal tool that allows weekday start changes?
Solution 1:
GNU cal has a --starting-day
option:
$ brew install gcal
$ alias cal='gcal --starting-day=1'
$ cal
June 2013
Mo Tu We Th Fr Sa Su
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
ncal
also starts weeks on mondays by default:
$ ncal
June 2013
Mo 3 10 17 24
Tu 4 11 18 25
We 5 12 19 26
Th 6 13 20 27
Fr 7 14 21 28
Sa 1 8 15 22 29
Su 2 9 16 23 30
Solution 2:
This Macworld.com OS X Hint shows some scripting to put Monday first…
cal | awk '{ print " "$0; getline; print " Mo Tu We Th Fr Sa Su"; \
getline; if (substr($0,1,2) == " 1") print " 1 "; \
do { prevline=$0; if (getline == 0) exit; print " " \
substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) }'
Result:
June 2013
Mo Tu We Th Fr Sa Su
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
Solution 3:
$ man cal
says: "The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of easter. The new format is a little cramped but it makes a year fit on a 25x80 terminal. If arguments are not specified, the current month is displayed". To me, it seems preferable to use ncal
as opposed to implementing an ugly hack.