| 1 | #!/bin/sh |
| 2 | # |
| 3 | # This code is released in public domain by Han Boetes <[email protected]> |
| 4 | |
| 5 | # This script tries to exec a pager by trying some known pagers if $PAGER is |
| 6 | # not set. |
| 7 | # |
| 8 | # Distributions/packagers can enhance this script with a |
| 9 | # distribution-specific mechanism to find the preferred pager. |
| 10 | |
| 11 | # The less -E and -F options exit immediately for short files, strip if present. |
| 12 | case "$LESS" in |
| 13 | *[EF]*) LESS=`echo "$LESS" | tr -d EF` |
| 14 | esac |
| 15 | |
| 16 | # Hopefully one of these is installed (no flamewars about preference please!): |
| 17 | # We don't use 'more' because it will exit if the file is too short. |
| 18 | # Worst case scenario we'll open the file in your editor. |
| 19 | for pager in "$PAGER" less most w3m pg i3-sensible-editor; do |
| 20 | if command -v "$pager" > /dev/null 2>&1; then |
| 21 | exec "$pager" "$@" |
| 22 | fi |
| 23 | done |