Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 3.9.0 -- UNRELEASED

* `clj-commons.ansi/wrap` splits a composed string into a sequence of composed strings for soft or hard wrapping
* `clj-commons.ansi/*color-enabled*` will now default to true when the environment variable COLOR_ENABLED is non-blank

## 3.8.0 -- 27 Apr 2026

Expand Down
13 changes: 10 additions & 3 deletions src/clj_commons/ansi.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
other font characteristics (bold, underline, italic, etc.) along with colors.

This will be false if the environment variable NO_COLOR is non-blank.

This will be true if the environment variable COLOR_ENABLED is non-blank.

Otherwise, the JVM system property `clj-commons.ansi.enabled` (if present) determines
the value; \"true\" enables colors, any other value disables colors.
Expand All @@ -30,8 +32,15 @@
then color will be enabled.

The nrepl.core check has been verified to work with Cursive, with `lein repl`, and with `clojure` (or `clj`)."
(if (seq (System/getenv "NO_COLOR"))
(cond
(seq (System/getenv "NO_COLOR"))
false

;; Set this when used inside a system that can properly parse the ANSI escape sequences.
(seq (System/getenv "COLOR_ENABLED"))
true

:else
(let [flag (System/getProperty "clj-commons.ansi.enabled")]
(cond
(some? flag) (to-boolean flag)
Expand Down Expand Up @@ -687,5 +696,3 @@
[& inputs]
(binding [*out* *err*]
(println (compose* inputs))))