Skip to content

Instantly share code, notes, and snippets.

@kolja
Created October 6, 2024 10:40
Show Gist options
  • Save kolja/8112c07549dabbc0ec17c918fe27fc2c to your computer and use it in GitHub Desktop.
Save kolja/8112c07549dabbc0ec17c918fe27fc2c to your computer and use it in GitHub Desktop.
gcal highlighter
#!/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