[BUG] `console.Console.pager` not respecting `PAGER`
See original GitHub issueDescribe the bug
Richโs build in pager does not seem to respect PAGER
on my machine, and behaves inconsistenly compared to using less
manually.
To Reproduce
"""rich_pager_debug.py"""
from rich import console
rich_console = console.Console(color_system="standard")
text = "[red]Hello world![/red]\n"
with rich_console.pager(styles=True):
rich_console.print(text)
No matter what I have set as PAGER
, I cannot get rich to properly display colors.
โฏ PAGER=less python rich_pager_debug.py
31mHello world!0m
โฏ PAGER='less -r' python rich_pager_debug.py
31mHello world!0m
โฏ PAGER='less -R' python rich_pager_debug.py
31mHello world!0m
However, manually calling less
results in colors as expected.
โฏ python rich_pager_debug.py | less -R

Platform
- macOS 11.6
- iTerm2
- macOS Terminal
- less 590
- less 487
Diagnose
Diagnosis
python -m rich.diagnose
โญโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ A high level console interface. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ <console width=250 ColorSystem.TRUECOLOR> โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ color_system = 'truecolor' โ
โ encoding = 'utf-8' โ
โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ
โ height = 70 โ
โ is_alt_screen = False โ
โ is_dumb_terminal = False โ
โ is_interactive = True โ
โ is_jupyter = False โ
โ is_terminal = True โ
โ legacy_windows = False โ
โ no_color = False โ
โ options = ConsoleOptions( โ
โ size=ConsoleDimensions(width=250, height=70), โ
โ legacy_windows=False, โ
โ min_width=1, โ
โ max_width=250, โ
โ is_terminal=True, โ
โ encoding='utf-8', โ
โ max_height=70, โ
โ justify=None, โ
โ overflow=None, โ
โ no_wrap=False, โ
โ highlight=None, โ
โ markup=None, โ
โ height=None โ
โ ) โ
โ quiet = False โ
โ record = False โ
โ safe_box = True โ
โ size = ConsoleDimensions(width=250, height=70) โ
โ soft_wrap = False โ
โ stderr = False โ
โ style = None โ
โ tab_size = 8 โ
โ width = 250 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
python -m rich._windows
platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)
python -m pip freeze | grep rich
rich @ file:///Users/pawlu/Library/Caches/pypoetry/artifacts/3a/dc/af/ff80071ba5431c81f40a3c922ff1585e7a3060b5549088275f57ee6975/rich-10.12.0-py3-none-any.whl
As always, appreicate the work on the library and continued development!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
invoke a pager to display results ยท Issue #86 ยท BurntSushi/ripgrep
Would it make sense to invoke a pager automatically if the tool detects that its output is not piped?
Read more >Ubuntu Manpage: console-log.conf - Main configuration file for ...
This mechanism can be used in any pager extension called from the logpager script. CONFIGURING THE LESS PAGER. For configuring the less pager,...
Read more >bug #52556: Octave stops writing to console on Windows 7
While the following command. printf("รครถรผ\n");. does not stop octave from writing to console, the same string in a function documentationย ...
Read more >How do I prevent 'git diff' from using a pager? - Stack Overflow
--no-pager to Git will tell it to not use a pager. Passing the option -F to less will tell it to not page...
Read more >Getting on the same page with Paging 3
You told us that the Paging 2.0 API was not enough - that you wanted easier ... The following examples will be in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@paw-lu Thanks for doing the investigation. Because weโre using pydoc, thereโs not much we can do. Weโve documented the behaviour for now. In the future we might have a better solution.
That actually works for me. I can see colour with both methods. Rich uses the stdlib pydoc module for the default paging, so it should use the same mechanism if you did
help()
from the REPL orpydoc sys
from the command line.Iโm on a similar platform to you, so Iโm not sure what could be different.
Can you print
os.environ
in your test code, just to check its not env var related.