Linux `cal` utility in landscape mode
The cal
utility in Linux does not, unfortunately allow one to output the calendar in landscape mode (4 columns or more). The default cal -y
output mode will display 3 columns. Here’s a hack-around:
- Download the latest release of util-linux
- Extract and edit the misc-utils/cal.c file.
- Find the
yearly
function. - Add a
cal_month m4
variable, which will hold the fourth column. - A little lower find
m3.next = NULL
and change it tom3.next = m4;
, addm4.next = NULL;
. - Inside the
for
loop change the3
to a4
in themonth += ...
clause. - And
make
- If all went well the output of
./cal -y
should yield four columns instead of three.
You can probably make cal
output 2, 5 or 6 columns in a similar fashion. Crazy hack, eh?
Update 4th September, 2014: I have sent in a patch to the `util-linux` library with a new feature – landscape mode. `-l` and `–landscape` flags will stretch the year output as much as two times. Pull request can be accessed on their GitHub upstream mirror: https://github.com/karelzak/util-linux/pull/117