about summary refs log tree commit diff
path: root/mcolor
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-08-02 23:16:58 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-08-02 23:16:58 +0200
commit688dd618180b5801a0ec7382b3745f4699a14f9b (patch)
treef37688bc5ca6f534ff10a966f82f2ca940fc8ab9 /mcolor
parenteb4e2c171d07bc39812e16cef969e5ea79e3c9d8 (diff)
downloadmblaze-688dd618180b5801a0ec7382b3745f4699a14f9b.tar.gz
mblaze-688dd618180b5801a0ec7382b3745f4699a14f9b.tar.xz
mblaze-688dd618180b5801a0ec7382b3745f4699a14f9b.zip
mcolor: no colors on dumb terminals
Diffstat (limited to 'mcolor')
-rwxr-xr-xmcolor3
1 files changed, 2 insertions, 1 deletions
diff --git a/mcolor b/mcolor
index b4a812c..5a60adf 100755
--- a/mcolor
+++ b/mcolor
@@ -7,7 +7,8 @@ true + /; exec awk -f "$0"; exit; / {}
 function co(n, c) { e = ENVIRON["MCOLOR_" n]; return e ? e : c }
 function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
 function so(s) { return sprintf("\033[1m%s\033[0m", s) }
-BEGIN { hdr = 1 }
+BEGIN { hdr = 1; if (match(ENVIRON["TERM"], "^(dumb|network|9term)")) dumb = 1 }
+dumb { print; next }
 /^$/ { hdr = 0 }
 /^-- $/ { ftr = 1 }
 /^--- .* ---/ { print fg(co("SEP",242), $0); ftr = 0; sig = 0; next }