June 17, 2024

Highlight current date with Cal (cli)

In .bashrc, add1:

# highlight current date when using cal
function cal() {
    if [ -t 1 ]; then ncal -b "${@}"; else command cal "${@}"; fi

I first tried this:

alias cal="if [ -t 1 ] ; then ncal -b ; else /usr/bin/cal ; fi"

but current date was no longer highlighted when I passed an option e.g. cal -3.

However, it seems that the alias:

alias cal='if [ -t 1 ]; then ncal -b "${@}"; else command cal "${@}"; fi'

takes options.
Still, I went for using a function as I read that using a function facilitate passing arguments to the command(s)”2.

The solution I found also suggest Replac[ing] /usr/bin/cal with command cal in case the user has cal installed in a non-standard location”, however, I don’t understand that bit.

  1. Shaun Mitchell↩︎

  2. Ibid↩︎

personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki cal

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88