aboutsummaryrefslogtreecommitdiff
path: root/i3-sensible-pager
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2011-09-25 18:45:51 +0100
committerMichael Stapelberg <michael@stapelberg.de>2011-09-25 18:46:37 +0100
commit6420b2b102bab214ad0bf1fa0f5e190f02984e82 (patch)
tree6666f4518093150a2e81551a5a6abb621290756e /i3-sensible-pager
parent1675499f1506e86e7b7339e1cc113af81c96db6b (diff)
downloadi3-6420b2b102bab214ad0bf1fa0f5e190f02984e82.tar.gz
i3-6420b2b102bab214ad0bf1fa0f5e190f02984e82.zip
Introduce the i3-sensible-{pager,editor,terminal} scripts
The former two provide fallbacks in case $PAGER or $EDITOR is not set (which might be more common than you think, because they have to be set in ~/.xsession, not in the shell configuration!) while the latter tries to launch a terminal emulator. The scripts are most prominently used in i3-nagbar, which alerts the user when the configuration is broken for some reason. Also, i3-sensible-terminal is used in the default configuration. This commit does not rely on the shell supporting ${PAGER:-less} anymore, which is not the case for 'fish'.
Diffstat (limited to 'i3-sensible-pager')
-rwxr-xr-xi3-sensible-pager15
1 files changed, 15 insertions, 0 deletions
diff --git a/i3-sensible-pager b/i3-sensible-pager
new file mode 100755
index 00000000..5af8d6b4
--- /dev/null
+++ b/i3-sensible-pager
@@ -0,0 +1,15 @@
+#!/bin/sh
+# This script tries to exec a pager by trying some known pagers if $PAGER is
+# not set.
+#
+# Distributions/packagers can enhance this script with a
+# distribution-specific mechanism to find the preferred pager.
+which $PAGER >/dev/null && exec $PAGER "$@"
+
+# Hopefully one of these is installed:
+which most >/dev/null && exec most "$@"
+which less >/dev/null && exec less "$@"
+# we don't use 'more' because it will exit if the file is 'too short'
+
+# If no pager is installed, try an editor
+exec i3-sensible-editor "$@"