Created
October 6, 2024 10:40
-
-
Save kolja/8112c07549dabbc0ec17c918fe27fc2c to your computer and use it in GitHub Desktop.
gcal highlighter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
;; gcal emphasizes the current day with angle brackets (e.g "< 1>"). | |
;; it doesn't support highlighting in a different color. | |
;; use this script to replace gcal's default highlighting with red: | |
;; | |
;; $ gcal . | gcal_highlighter | |
(require '[clojure.string :as str]) | |
(defn red [s] (str "\u001b[31m" s "\u001b[0m")) | |
(defn highlight-day [calendar-output] | |
(let [today (.format (java.time.LocalDate/now) | |
(java.time.format.DateTimeFormatter/ofPattern "d"))] | |
(str/replace calendar-output | |
(re-pattern (str "<(\\s*)(" today ")>")) | |
#(str " " (%1 1) (red (%1 2)) " ")))) ;; captures are passed as a single vector. | |
(println (highlight-day (slurp *in*))) | |
;# vim:ft=clojure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment