##// END OF EJS Templates
pager: Add a configuration to enable/disable the pager for certain commands...
David Soria Parra <dsp <at> php.net> -
r6417:13fafd8c default
parent child Browse files
Show More
@@ -1,35 +1,60 b''
1 1 # pager.py - display output using a pager
2 2 #
3 3 # Copyright 2008 David Soria Parra <dsp@php.net>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7 #
8 8 # To load the extension, add it to your .hgrc file:
9 9 #
10 10 # [extension]
11 11 # hgext.pager =
12 12 #
13 13 # To set the pager that should be used, set the application variable:
14 14 #
15 15 # [pager]
16 16 # pager = LESS='FSRX' less
17 17 #
18 18 # If no pager is set, the pager extensions uses the environment
19 19 # variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager
20 20 # is used.
21 21 #
22 22 # If you notice "BROKEN PIPE" error messages, you can disable them
23 23 # by setting:
24 24 #
25 25 # [pager]
26 26 # quiet = True
27 #
28 # You can disable the pager for certain commands by adding them to the
29 # pager.ignore list:
30 #
31 # [pager]
32 # ignore = version, help, update
33 #
34 # You can also enable the pager only for certain commands using pager.attend:
35 #
36 # [pager]
37 # attend = log
38 #
39 # If pager.attend is present, pager.ignore will be ignored.
40 #
41 # To ignore global commands like 'hg version' or 'hg help', you have to specify them
42 # in the global .hgrc
27 43
28 44 import sys, os, signal
45 from mercurial import dispatch
29 46
30 47 def uisetup(ui):
31 p = ui.config("pager", "pager", os.environ.get("PAGER"))
32 if p and sys.stdout.isatty():
33 if ui.configbool('pager', 'quiet'):
34 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
35 sys.stderr = sys.stdout = os.popen(p, "wb")
48 def pagecmd(ui, options, cmd, cmdfunc):
49 p = ui.config("pager", "pager", os.environ.get("PAGER"))
50 if p and sys.stdout.isatty():
51 attend = ui.configlist('pager', 'attend')
52 if (cmd in attend or
53 (cmd not in ui.configlist('pager', 'ignore') and not attend)):
54 sys.stderr = sys.stdout = os.popen(p, "wb")
55 if ui.configbool('pager', 'quiet'):
56 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
57 return oldrun(ui, options, cmd, cmdfunc)
58
59 oldrun = dispatch._runcommand
60 dispatch._runcommand = pagecmd
General Comments 0
You need to be logged in to leave comments. Login now