aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-12 00:01:51 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-12 00:01:51 +0100
commit40379705b93986266275b3c067b4b4e9b6585f13 (patch)
tree86b176f8614b5c98b8fd42395dd8e6a57fbfbe75
parentb17ffeb56aa179fcc0317475ede5b5523523524d (diff)
Allow the use of env-vars to customize colors
-rw-r--r--grab.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/grab.c b/grab.c
index 2b18167..e063f7d 100644
--- a/grab.c
+++ b/grab.c
@@ -329,10 +329,20 @@ cmdy(struct sv sv, struct ops ops, size_t i, const char *filename)
void
putm(struct sv sv, const char *filename)
{
+ static const char *fnc, *sepc;
+
+ if (!fnc) {
+ const char *s;
+
+ fnc = (s = getenv("GRAB_COLOR_FNAME")) && *s ? s : "35";
+ sepc = (s = getenv("GRAB_COLOR_SEP")) && *s ? s : "36";
+ }
+
if (fflag || filecnt > 1) {
- if (color)
- printf("\33[35m%s\33[36m%c\33[0m", filename, zflag ? '\0' : ':');
- else
+ if (color) {
+ printf("\33[%sm%s\33[%sm%c\33[0m", fnc, filename, sepc,
+ zflag ? '\0' : ':');
+ } else
printf("%s%c", filename, zflag ? '\0' : ':');
}
fwrite(sv.p, 1, sv.len, stdout);