mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-28 08:03:09 +08:00

This is our traditional behavior; "man" and "git" do the same. (cherry picked from commit b83f3b0e982c89e2dc2c2fc23b950b84d7ee8d19) Proposing this for 3.7.1 because I think see this as regression in 3.7.0 - a user might have installed bat for syntax highlighting only.
32 lines
749 B
Fish
32 lines
749 B
Fish
function __fish_anypager --description "Print a pager to use"
|
|
set -l pager
|
|
# We prefer $PAGER if we have it
|
|
set -q PAGER
|
|
and echo $PAGER | read -at pager
|
|
|
|
# or even $MANPAGER if we're allowed to
|
|
if test "$argv[1]" = "--with-manpager"
|
|
set -q MANPAGER
|
|
and echo $MANPAGER | read -at pager
|
|
end
|
|
|
|
# We use them if they *exist*
|
|
if command -q $pager[1]
|
|
printf %s\n $pager
|
|
return 0
|
|
end
|
|
|
|
# Cheesy hardcoded list of pagers.
|
|
for cmd in less bat lv most more
|
|
if command -q $cmd
|
|
echo -- $cmd
|
|
return 0
|
|
end
|
|
end
|
|
|
|
# We have no pager.
|
|
# We could fall back to "cat",
|
|
# but in some cases that's probably not helpful.
|
|
return 1
|
|
end
|