"cal"コマンドで色で祝日を強調する方法

cal色や類似の注文で休日を強調したいです。

私はOS XとUbuntu 14を使用しています。この機能を有効にする簡単な方法はありますか?

ベストアンサー1

私はこれが可能な標準だとは思わないがcalgcalGNUカレンダー

テキストを強調表示するには、-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 [...]

正確に強調された休日の例もあります。手動:

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).

例:

  • 現在の日付を青で強調表示し、その月の米国/アラスカ(US_AK)の祝日を緑で強調表示するには、次の手順を実行します。

    gcal -H '\e[34m:\e[0m:\e[32m:\e[0m' -q US_AK
    

    注:34前景色はANSIコード、32前景色はANSIコードです。

    結果:

    ここに画像の説明を入力してください。

  • 2014年中、31緑の背景()に現在の日付は赤()で表示され、42中国の祝日()はフクシア()の背景に黄色()で表示されます。CN3345

    gcal -H '\e[31;42m:\e[0m:\e[33;45m:\e[0m' -q CN 2014
    

info gcalオプション説明以下にすべての国コードを見つけることができます-q

おすすめ記事