]> git.phdru.name Git - dotfiles.git/commitdiff
bin/PS: pass option '-S' to 'less'
authorOleg Broytman <phd@phdru.name>
Wed, 1 Mar 2017 21:17:34 +0000 (00:17 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 1 Mar 2017 21:17:34 +0000 (00:17 +0300)
bin/PS

diff --git a/bin/PS b/bin/PS
index db86d2b1b6a1e0e5ea672089284de01d770a423a..67574b554436acdc20ac245993d489be5183fd0c 100755 (executable)
--- a/bin/PS
+++ b/bin/PS
@@ -7,4 +7,11 @@ if "--sort=" not in args:
    args += " --sort=user"
 
 pager = os.environ.get("PAGER", "more")
+# if pager is 'less', option '-S' must be passed to it
+if pager == 'less':
+    less = os.environ.get("LESS") or ''
+    opt = 'S'
+    if opt not in less:
+        less = opt + less
+    os.environ["LESS"] = less
 os.system("ps %s | %s" % (args, pager))