fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
6d0cd3d9b
master
1# localization: skip(private) 2if not type -q apropos 3function __fish_apropos 4end 5exit 6end 7 8if test ( __fish_uname ) = Darwin 9and test -x /usr/libexec/makewhatis 10 11function __fish_apropos 12# macOS has a read only filesystem where the whatis database should be. 13 14if functions -q apropos|| test "$ ( command -v apropos ) " != /usr/bin/apropos 15__fish_without_manpager apropos" $argv " 16return 17end 18 19# The whatis database is non-existent, so apropos tries (and fails) to create it every time, 20# which can take seconds. 21# 22# Instead, we build a whatis database in the user cache directory 23# and override the MANPATH using that directory before we run `apropos` 24# 25# the cache is rebuilt once a week. 26set -l dir( __fish_make_cache_dir apropos) 27set -l whatis$dir /whatis 28set -l max_age600000 # like a week 29set -l age$max_age 30 31if test -f " $whatis " 32set age( path mtime -R --$whatis ) 33end 34 35 MANPATH=" $dir " __fish_without_manpager /usr/bin/apropos" $argv " 36 37if test $age -ge $max_age 38set -l sh( __fish_posix_shell ) 39$sh -c'( "$@" ) >/dev/null 2>&1 </dev/null &' --\ 40 /usr/libexec/makewhatis -o" $whatis " \ 41( /usr/bin/manpath | string split :| xargs realpath) 42end 43end 44else 45function __fish_apropos 46# we only ever prefix match for completions. This also ensures results for bare apropos <TAB> 47# (apropos '' gives no results, but apropos '^' lists all manpages) 48__fish_without_manpager apropos" $argv " 49end 50end