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.
personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki cal