Make "less" the default pager, similar to Git
This commit is contained in:
parent
16dbd019bc
commit
0872f80d97
1 changed files with 28 additions and 1 deletions
29
src/report.h
29
src/report.h
|
|
@ -629,7 +629,34 @@ public:
|
||||||
});
|
});
|
||||||
|
|
||||||
OPTION(report_t, output_); // -o
|
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<string>& whence, const value_t& text) {
|
||||||
|
string cmd(text.to_string());
|
||||||
|
if (cmd == "" || cmd == "false" || cmd == "off" ||
|
||||||
|
cmd == "none" || cmd == "no" || cmd == "disable")
|
||||||
|
option_t<report_t>::off();
|
||||||
|
else
|
||||||
|
option_t<report_t>::on_with(whence, text);
|
||||||
|
});
|
||||||
|
|
||||||
OPTION(report_t, payee_as_account);
|
OPTION(report_t, payee_as_account);
|
||||||
|
|
||||||
OPTION_(report_t, pending, DO() { // -C
|
OPTION_(report_t, pending, DO() { // -C
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue