Show More
@@ -1,62 +1,64 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 of the |
|
6 | 6 | # GNU General Public License version 2, 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 | # Run "hg help pager" to get info on configuration. |
|
14 | 14 | |
|
15 | 15 | '''browse command output with an external pager |
|
16 | 16 | |
|
17 | 17 | To set the pager that should be used, set the application variable:: |
|
18 | 18 | |
|
19 | 19 | [pager] |
|
20 | 20 | pager = LESS='FSRX' less |
|
21 | 21 | |
|
22 |
If no pager is set, the pager extensions uses the environment variable |
|
|
23 | If neither pager.pager, nor $PAGER is set, no pager is used. | |
|
22 | If no pager is set, the pager extensions uses the environment variable | |
|
23 | $PAGER. If neither pager.pager, nor $PAGER is set, no pager is used. | |
|
24 | 24 | |
|
25 |
If you notice "BROKEN PIPE" error messages, you can disable them by |
|
|
25 | If you notice "BROKEN PIPE" error messages, you can disable them by | |
|
26 | setting:: | |
|
26 | 27 | |
|
27 | 28 | [pager] |
|
28 | 29 | quiet = True |
|
29 | 30 | |
|
30 | 31 | You can disable the pager for certain commands by adding them to the |
|
31 | 32 | pager.ignore list:: |
|
32 | 33 | |
|
33 | 34 | [pager] |
|
34 | 35 | ignore = version, help, update |
|
35 | 36 | |
|
36 |
You can also enable the pager only for certain commands using |
|
|
37 | You can also enable the pager only for certain commands using | |
|
38 | pager.attend:: | |
|
37 | 39 | |
|
38 | 40 | [pager] |
|
39 | 41 | attend = log |
|
40 | 42 | |
|
41 | 43 | If pager.attend is present, pager.ignore will be ignored. |
|
42 | 44 | |
|
43 |
To ignore global commands like "hg version" or "hg help", you have to |
|
|
44 | them in the global .hgrc | |
|
45 | To ignore global commands like "hg version" or "hg help", you have to | |
|
46 | specify them in the global .hgrc | |
|
45 | 47 | ''' |
|
46 | 48 | |
|
47 | 49 | import sys, os, signal |
|
48 | 50 | from mercurial import dispatch, util, extensions |
|
49 | 51 | |
|
50 | 52 | def uisetup(ui): |
|
51 | 53 | def pagecmd(orig, ui, options, cmd, cmdfunc): |
|
52 | 54 | p = ui.config("pager", "pager", os.environ.get("PAGER")) |
|
53 | 55 | if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |
|
54 | 56 | attend = ui.configlist('pager', 'attend') |
|
55 | 57 | if (cmd in attend or |
|
56 | 58 | (cmd not in ui.configlist('pager', 'ignore') and not attend)): |
|
57 | 59 | sys.stderr = sys.stdout = util.popen(p, "wb") |
|
58 | 60 | if ui.configbool('pager', 'quiet'): |
|
59 | 61 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
60 | 62 | return orig(ui, options, cmd, cmdfunc) |
|
61 | 63 | |
|
62 | 64 | extensions.wrapfunction(dispatch, '_runcommand', pagecmd) |
General Comments 0
You need to be logged in to leave comments.
Login now