From 373fad75e19a2f24db512621b8cedb627d03d49d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Aug 2014 16:01:16 +0200 Subject: Add some color --- src/nix-env/nix-env.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/nix-env/nix-env.cc') diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 44296c7b62..ad0f4bdd71 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -847,13 +847,6 @@ static VersionDiff compareVersionAgainstSet( } -static string colorString(const string & s) -{ - if (!isatty(STDOUT_FILENO)) return s; - return "\e[1;31m" + s + "\e[0m"; -} - - static void queryJSON(Globals & globals, vector & elems) { JSONObject topObj(cout); @@ -1056,7 +1049,8 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) } } else { string column = (string) "" + ch + " " + version; - if (diff == cvGreater) column = colorString(column); + if (diff == cvGreater && isatty(STDOUT_FILENO)) + column = ANSI_RED + column + ANSI_NORMAL; columns.push_back(column); } } -- cgit 1.4.1