How to make the `cal` tool in OSX highlight the current day

calosx

In Ubuntu and Fedora, when I type cal on the command line I get an ASCII calendar with the current day highlighted.

In OSX, when I type cal, I get an ASCII calendar but no day is highlighted.

How can I get the highlighting of the current date in OSX?

Best Answer

The following prints the current date with a reversed field which is replaced in cal by sed.

ptd=$(date -j +%d)
ctd=$(printf "\033[0;7m"$ptd"\033[0m")
cal | sed 's/'"$ptd"'/'"$ctd"'/'