summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalless38
1 files changed, 38 insertions, 0 deletions
diff --git a/localless b/localless
new file mode 100755
index 0000000..773f7a5
--- /dev/null
+++ b/localless
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright © 2021 Jonas Smedegaard <dr@jones.dk>
+# Description: pipe a command to less with INT signal blocked
+#
+# This program is free software;
+# you can redistribute it and/or modify it
+# under the terms of the GNU General Public License
+# as published by the Free Software Foundation;
+# either version 2, or (at your option) any later version.
+#
+# Thanks to Jakub Wilk <jwilk@debian.org> for the trick
+#
+# Depends: less
+
+set -e
+
+PRG=$(basename "$0")
+
+showhelp() {
+ cat <<EOF
+Usage: $PRG command [opetions...]
+
+Example: $PRG journalctl -ef
+EOF
+}
+
+exit1() {
+ echo "ERROR: $1"
+ exit 1
+}
+
+if [ $# -eq 0 ]; then
+ showhelp
+ exit1 "not enough parameters"
+fi
+
+exec env --ignore-signal=INT "$@" | less