13
# To set the pager that should be used, set the application variable:
16
# pager = LESS='FSRX' less
18
# If no pager is set, the pager extensions uses the environment
19
# variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager
22
# If you notice "BROKEN PIPE" error messages, you can disable them
13
# Run "hg help pager" to get info on configuration.
15
'''browse command output with external pager
17
To set the pager that should be used, set the application variable:
20
pager = LESS='FSRX' less
22
If no pager is set, the pager extensions uses the environment
23
variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager
26
If you notice "BROKEN PIPE" error messages, you can disable them
32
You can disable the pager for certain commands by adding them to the
36
ignore = version, help, update
38
You can also enable the pager only for certain commands using pager.attend:
43
If pager.attend is present, pager.ignore will be ignored.
45
To ignore global commands like "hg version" or "hg help", you have to specify
46
them in the global .hgrc
28
49
import sys, os, signal
50
from mercurial import dispatch, util, extensions
31
p = ui.config("pager", "pager", os.environ.get("PAGER"))
32
if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
33
if ui.configbool('pager', 'quiet'):
34
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
35
sys.stderr = sys.stdout = os.popen(p, "wb")
53
def pagecmd(orig, ui, options, cmd, cmdfunc):
54
p = ui.config("pager", "pager", os.environ.get("PAGER"))
55
if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
56
attend = ui.configlist('pager', 'attend')
58
(cmd not in ui.configlist('pager', 'ignore') and not attend)):
59
sys.stderr = sys.stdout = util.popen(p, "wb")
60
if ui.configbool('pager', 'quiet'):
61
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
62
return orig(ui, options, cmd, cmdfunc)
64
extensions.wrapfunction(dispatch, '_runcommand', pagecmd)