Re: cal: add option to highlight the current day

Crystal Kolipe <[email protected]> Sat, 01 Aug 2026 20:01:19 -0000
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
On Sat, Aug 01, 2026 at 07:47:25PM -0000, Crystal Kolipe wrote:
> On Sat, Aug 01, 2026 at 04:08:06AM +0200, Piotr Durlej wrote:
> > On Fri, Jul 31, 2026 at 05:29:15PM -0700, patrick keshishian wrote:
> > > 
> > > How about an environment variable to enable the highlight for
> > > those who want this option, which can be put in their .profile,
> > > retaining the age-long behavior as default for the rest?
> > > 
> > > Something like the following patch on top of your proposal.
> > > 
> > > --patrick
> > 
> > I'm not sure why this would be added to the base system cal(1), especially
> > when ncal(1) already exists as a package and does the job.
> 
> If you just want highlighting of the current day, why not use the base cal
> with sed:
> 
> $ cal | sed s/" `date +%e`"/"^[[92m&^[[39m"/
> 
> You can easily make that a shell alias.
> 
> The space before `date +%e` in the first quoted string ensures that single
> digits only match the intended day.
> 
> Note that ^[ is escape, so if you're typing this at the console, then hit
> control-v and then escape to enter the sequence.

Actually, it's better to match on either of the trailing space or newline:

$ cal | sed -E s/"`date +%e`( |$)"/"^[[92m&^[[39m"/