From 0872f80d97fd7d4330e8cc4d0b88bbe2170e5eb1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 28 Oct 2009 02:29:22 -0400 Subject: Make "less" the default pager, similar to Git --- src/report.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/report.h') diff --git a/src/report.h b/src/report.h index b6133512..6d63a0e9 100644 --- a/src/report.h +++ b/src/report.h @@ -629,7 +629,34 @@ public: }); OPTION(report_t, output_); // -o - OPTION(report_t, pager_); + + OPTION__ + (report_t, pager_, + CTOR(report_t, pager_) { +#if 1 + if (! std::getenv("PAGER")) { + bool have_less = false; + if (exists(path("/opt/local/bin/less")) || + exists(path("/usr/local/bin/less")) || + exists(path("/usr/bin/less"))) + have_less = true; + + if (have_less) { + on(none, "less"); + setenv("LESS", "--quit-if-one-screen -R", 0); + } + } +#endif + } + virtual void on_with(const optional& whence, const value_t& text) { + string cmd(text.to_string()); + if (cmd == "" || cmd == "false" || cmd == "off" || + cmd == "none" || cmd == "no" || cmd == "disable") + option_t::off(); + else + option_t::on_with(whence, text); + }); + OPTION(report_t, payee_as_account); OPTION_(report_t, pending, DO() { // -C -- cgit v1.2.3