From 62d11a71592cc5b273bf1e9e330cc59944639b06 2016-02-20 22:55:40 From: Dmitry Zotikov Date: 2016-02-20 22:55:40 Subject: [PATCH] Ensure pager interprets escape sequences If less is specified in $PAGER, but $LESS either doesn't exist or doesn't contain `-r` option, append `-r` to the pager command string. --- diff --git a/IPython/core/page.py b/IPython/core/page.py index 35677d3..340d703 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -308,6 +308,13 @@ def get_pager_cmd(pager_cmd=None): pager_cmd = os.environ['PAGER'] except: pager_cmd = default_pager_cmd + + if pager_cmd == 'less': + try: + os.getenv('LESS').index('-r') + except (ValueError, AttributeError): + pager_cmd += ' -r' + return pager_cmd