2023-10-28 16:31:24 +08:00
|
|
|
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
|
2023-12-06 16:33:05 +08:00
|
|
|
if test "$argv[1]" = --with-manpager
|
2023-10-28 16:31:24 +08:00
|
|
|
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.
|
2024-09-14 13:14:22 +08:00
|
|
|
for cmd in less lv most more
|
2023-10-28 16:31:24 +08:00
|
|
|
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
|