From: Oleg Broytman Date: Wed, 20 Apr 2016 13:38:39 +0000 (+0300) Subject: init.py: pass options '-F', '-R' and '-X' to 'less' X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=commitdiff_plain;h=7f5eb416029fbcd33bb4e1b2dd78c43ac279456f init.py: pass options '-F', '-R' and '-X' to 'less' --- diff --git a/lib/python/init.py b/lib/python/init.py index a5e6323..7ef24db 100644 --- a/lib/python/init.py +++ b/lib/python/init.py @@ -117,11 +117,20 @@ def init(): except (ImportError, locale.Error): pass # no locale support or unsupported locale - # set displayhook + # set displayhook and excepthook from pprint import pprint pager = os.environ.get("PAGER") or 'more' + # if your pager is 'less', options '-F' and '-R' must be passed to it, + # and option '-X' is very much recommended + if pager == 'less': + less = os.environ.get("LESS") or '' + for opt in 'X', 'R', 'F': + if opt not in less: + less = opt + less + os.environ["LESS"] = less + class BasePager: def write(self, value): self.stdin.write(value)