mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-22 01:51:14 -03:00
Compare commits
1 Commits
47a3757f73
...
macos-apro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
233355bc9b |
@@ -38,7 +38,7 @@ complete -c man -n 'string match -q -- "*/*" (commandline -t | string collect)'
|
||||
if command -q man
|
||||
# We have a conditionally-defined man function,
|
||||
# so we need to check for existence here.
|
||||
if echo | MANPAGER=cat command man -l - &>/dev/null
|
||||
if echo | __fish_without_manpager command man -l - &>/dev/null
|
||||
complete -c man -s l -l local-file -d "Local file" -r
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,7 @@ if not type -q apropos
|
||||
exit
|
||||
end
|
||||
|
||||
# Check for macOS Catalina or above.
|
||||
if test (__fish_uname) = Darwin
|
||||
and test (string match -r "^\d+" "$(uname -r)") -ge 19
|
||||
and test -x /usr/libexec/makewhatis
|
||||
|
||||
set -l dir
|
||||
@@ -18,6 +16,11 @@ if test (__fish_uname) = Darwin
|
||||
end
|
||||
|
||||
function __fish_apropos -V dir
|
||||
if test "$(command -v apropos)" != /usr/bin/apropos
|
||||
__fish_without_manpager apropos "$argv"
|
||||
return
|
||||
end
|
||||
|
||||
# macOS 10.15 "Catalina" has a read only filesystem where the whatis database should be.
|
||||
# The whatis database is non-existent, so apropos tries (and fails) to create it every time,
|
||||
# which can take seconds.
|
||||
@@ -34,17 +37,19 @@ if test (__fish_uname) = Darwin
|
||||
set age (path mtime -R -- $whatis)
|
||||
end
|
||||
|
||||
MANPATH="$dir" MANPAGER=cat WHATISPAGER=cat apropos "$argv"
|
||||
MANPATH="$dir" __fish_without_manpager apropos "$argv"
|
||||
|
||||
if test $age -ge $max_age
|
||||
test -d "$dir" || mkdir -m 700 -p $dir
|
||||
/bin/sh -c '( "$@" ) >/dev/null 2>&1 </dev/null &' -- /usr/libexec/makewhatis -o "$whatis" (/usr/bin/manpath | string split : | xargs realpath)
|
||||
/bin/sh -c '( "$@" ) >/dev/null 2>&1 </dev/null &' -- \
|
||||
/usr/libexec/makewhatis -o "$whatis" \
|
||||
(/usr/bin/manpath | string split : | xargs realpath)
|
||||
end
|
||||
end
|
||||
else
|
||||
function __fish_apropos
|
||||
# we only ever prefix match for completions. This also ensures results for bare apropos <TAB>
|
||||
# (apropos '' gives no results, but apropos '^' lists all manpages)
|
||||
MANPAGER=cat WHATISPAGER=cat apropos "$argv"
|
||||
__fish_without_manpager apropos "$argv"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ function __fish_print_help --description "Print help for the specified fish func
|
||||
end
|
||||
set -l args -l (path filter -- $man1/$item.1 $man1/$item.1.gz)[1]
|
||||
# Work around macOS/FreeBSD man not supporting -l yet (only mandoc really needs it).
|
||||
if not MANPAGER=cat WHATISPAGER=cat command man -l $args[2] &>/dev/null
|
||||
if not __fish_without_manpager command man -l $args[2] &>/dev/null
|
||||
set -e args[1]
|
||||
end
|
||||
command man $args
|
||||
|
||||
7
share/functions/__fish_without_manpager.fish
Normal file
7
share/functions/__fish_without_manpager.fish
Normal file
@@ -0,0 +1,7 @@
|
||||
function __fish_without_manpager
|
||||
MANPAGER=cat WHATISPAGER=cat if test "$argv[1]" = command
|
||||
command $argv[2..]
|
||||
else
|
||||
$argv
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user