我不认为这是可能的标准cal
,但你可能想看看gcal
,在GNU日历。
要突出显示您需要传递-H
选项的文本:
-H text
--highlighting=text
Set highlighting sequence / marking character pairs explicitly.
In this sense, highlighting sequences are control character sequences
which cause a color or intensity switch in output text. Typical control
character sequences are the ANSI escape sequences [...]
Run Code Online (Sandbox Code Playgroud)
手册中甚至有突出显示假期的例子:
For example:
-H \x20:\x20:\x1:# respectively
--highlighting=\x20:\x20:\x1:#
marks the actual day like ‘\x20actual date\x20’6 and the holiday date like
‘\x1holiday date#’ using the given marking characters.
-H \x1b[34;42m:\x1b[0;40m or
-H \033[34;42m:\033[0;40m or
-H \E[34;42m:\E[0;40m
defines a starting ANSI escape highlighting sequence ‘\x1b[34;42m’ used for
actual day and ending ANSI escape highlighting sequence ‘\x1b[0;40m’ with no
given highlighting sequence for holidays, so default highlighting sequences for
holidays are used (non-given entries are always skipped).
Run Code Online (Sandbox Code Playgroud)
例子:
要以蓝色突出显示当前日期,并以绿色突出显示当前月份美国/阿拉斯加 (US_AK) 的假期:
gcal -H '\e[34m:\e[0m:\e[32m:\e[0m' -q US_AK
Run Code Online (Sandbox Code Playgroud)
注:34
前景蓝32
为ANSI代码,前景绿为ANSI代码
结果:
在整个 2014 年以红色 ( 31
) 显示绿色背景 ( 42
) 和CN
黄色 ( 33
) 洋红色 ( 45
)节假日
gcal -H '\e[31;42m:\e[0m:\e[33;45m:\e[0m' -q CN 2014
Run Code Online (Sandbox Code Playgroud)您将在选项info gcal
说明下找到所有国家/地区代码-q
。