commit b13bf08f00eb231123c4a909eeb502ed48755e3f
parent 25805f0bbcd8f1658bc60c837e31432ed76cba58
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Tue, 2 Dec 2025 20:17:33 +0000
NO_COLOR environment variable disables color sequences
Diffstat:
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -308,10 +308,11 @@ Flags:
rather than a tree
Environment:
-- `CLICOLOR`: when set to a non-empty value, use ANSI escape sequences to
- color the output
+- `CLICOLOR`: when set to a non-empty value, and `NO_COLOR` is unset or empty,
+ use ANSI escape sequences to color the output
- `LC_CTYPE`: when it contains `UTF`, the tree is displayed using Unicode
graphic characters instead of ASCII
+- `NO_COLOR`: when set to a non-empty value, no ANSI escape sequence is output
- `PASHAGE_DIR`: database directory to use instead of `~/.passage/store`
- `PASSAGE_DIR`: database directory to use instead of `~/.passage/store`
when `PASHAGE_DIR` is unset
@@ -348,8 +349,9 @@ Flags:
storing it into the database
Environment:
-- `CLICOLOR`: when set to a non-empty value, use ANSI escape sequences to
- color the output
+- `CLICOLOR`: when set to a non-empty value, and `NO_COLOR` is unset or empty,
+ use ANSI escape sequences to color the output
+- `NO_COLOR`: when set to a non-empty value, no ANSI escape sequence is output
- `PASHAGE_AGE`: external command to use instead of `age`
- `PASHAGE_DIR`: database directory to use instead of `~/.passage/store`
- `PASHAGE_IDENTITIES_FILE`: _identity_ file to use instead of
@@ -423,8 +425,9 @@ filter them through `grep(1)` using the given options, and outputs all the
matching lines and the corresponding secret.
Environment:
-- `CLICOLOR`: when set to a non-empty value, use ANSI escape sequences to
- color the output
+- `CLICOLOR`: when set to a non-empty value, and `NO_COLOR` is unset or empty,
+ use ANSI escape sequences to color the output
+- `NO_COLOR`: when set to a non-empty value, no ANSI escape sequence is output
- `PASHAGE_AGE`: external command to use instead of `age`
- `PASHAGE_DIR`: database directory to use instead of `~/.passage/store`
- `PASHAGE_IDENTITIES_FILE`: _identity_ file to use instead of
@@ -544,10 +547,11 @@ Flags:
- `-r` or `--raw`: display the results as a raw list of secrets
Environment:
-- `CLICOLOR`: when set to a non-empty value, use ANSI escape sequences to
- color the output
+- `CLICOLOR`: when set to a non-empty value, and `NO_COLOR` is unset or empty,
+ use ANSI escape sequences to color the output
- `LC_CTYPE`: when it contains `UTF`, the tree is displayed using Unicode
graphic characters instead of ASCII
+- `NO_COLOR`: when set to a non-empty value, no ANSI escape sequence is output
- `PASHAGE_DIR`: database directory to use instead of `~/.passage/store`
- `PASSAGE_DIR`: database directory to use instead of `~/.passage/store`
when `PASHAGE_DIR` is unset
diff --git a/pashage.1 b/pashage.1
@@ -358,7 +358,9 @@ The following environment variables affect the execution of
.\" but that compresses the second columns way too much.
.Bl -tag -width XXXXXXXX
.It Ev CLICOLOR
-when set to a non-empty value, use ANSI escape sequences to color the output
+when set to a non-empty value, and
+.Ev NO_COLOR
+is unset or empty, use ANSI escape sequences to color the output
.It Ev EDITOR
editor command to use instead of
.Xr vi 1
@@ -369,6 +371,8 @@ is not set
when it contains
.Qq UTF ,
the tree is displayed using Unicode graphic characters instead of ASCII
+.It NO_COLOR
+when set to a non-empty value, no ANSI escape sequence is output
.It Ev PASHAGE_AGE
external command to use instead of
.Xr age 1
diff --git a/src/run.sh b/src/run.sh
@@ -60,7 +60,7 @@ RED_TEXT=""
BLUE_TEXT=""
UNDERLINE_TEXT=""
NO_UNDERLINE_TEXT=""
-if [ -n "${CLICOLOR-}" ]; then
+if [ -z "${NO_COLOR-}" ] && [ -n "${CLICOLOR-}" ]; then
BOLD_TEXT="$(printf '\033[1m')"
NORMAL_TEXT="$(printf '\033[0m')"
RED_TEXT="$(printf '\033[31m')"