X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3;a=blobdiff_plain;f=i3-sensible-pager;h=386e29886ff82d29e8a56034eacfcfe87ce5eaac;hp=32f30aff895e670d39a3755e07870bf287e5358f;hb=HEAD;hpb=ee43861fc412d37585f43ea085d4c498376d0fdf diff --git a/i3-sensible-pager b/i3-sensible-pager index 32f30aff..386e2988 100755 --- a/i3-sensible-pager +++ b/i3-sensible-pager @@ -1,15 +1,18 @@ #!/bin/sh +# +# This code is released in public domain by Han Boetes + # 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. -[ -n "$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 "$@" +# Hopefully one of these is installed (no flamewars about preference please!): +# We don't use 'more' because it will exit if the file is too short. +# Worst case scenario we'll open the file in your editor. +for pager in "$PAGER" less most w3m pg i3-sensible-editor; do + if command -v "$pager" > /dev/null 2>&1; then + exec "$pager" "$@" + fi +done