about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T19·26+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-08-20T19·44+0200
commit43579c9799e93120620481b72785f382f9c264d9 (patch)
tree468a9d9dee86088c2a874728c9dad7da56dd4002
parent9481f7769390b934fba92441be32b39287cc93d7 (diff)
Use pager for more commands
-rw-r--r--src/nix-env/nix-env.cc7
-rw-r--r--src/nix-store/nix-store.cc2
2 files changed, 8 insertions, 1 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 325c8b928fea..5116d955fe09 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -977,6 +977,9 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
         return;
     }
 
+    bool tty = isatty(STDOUT_FILENO);
+    RunPager pager;
+
     Table table;
     std::ostringstream dummy;
     XMLWriter xml(true, *(xmlOutput ? &cout : &dummy));
@@ -1049,7 +1052,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
                     }
                 } else {
                     string column = (string) "" + ch + " " + version;
-                    if (diff == cvGreater && isatty(STDOUT_FILENO))
+                    if (diff == cvGreater && tty)
                         column = ANSI_RED + column + ANSI_NORMAL;
                     columns.push_back(column);
                 }
@@ -1240,6 +1243,8 @@ static void opListGenerations(Globals & globals, Strings opFlags, Strings opArgs
     int curGen;
     Generations gens = findGenerations(globals.profile, curGen);
 
+    RunPager pager;
+
     for (Generations::iterator i = gens.begin(); i != gens.end(); ++i) {
         tm t;
         if (!localtime_r(&i->creationTime, &t)) throw Error("cannot convert time");
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 24ecf84142b0..8c3744824ce6 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -299,6 +299,8 @@ static void opQuery(Strings opFlags, Strings opArgs)
         else if (*i == "--include-outputs") includeOutputs = true;
         else throw UsageError(format("unknown flag ‘%1%’") % *i);
 
+    RunPager pager;
+
     switch (query) {
 
         case qOutputs: {