2019-10-06 21:14:10 +08:00
|
|
|
# This function is typically bound to Alt-W, it is used to list man page entries
|
|
|
|
# for the command under the cursor.
|
2020-07-11 19:54:19 +08:00
|
|
|
function __fish_whatis_current_token -d "Show man page entries or function description related to the token under the cursor"
|
|
|
|
set -l token (commandline -pt)
|
2019-10-06 21:14:10 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
test -n "$token"
|
|
|
|
or return
|
2020-07-11 19:54:19 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
set -l desc "$token: nothing appropriate."
|
2020-07-11 19:54:19 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
set -l tokentype (type --type $token 2>/dev/null)
|
2020-07-11 19:54:19 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
switch "$tokentype"
|
|
|
|
case function
|
|
|
|
set -l funcinfo (functions $token --details --verbose)
|
2020-07-11 19:54:19 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
test $funcinfo[5] != n/a
|
|
|
|
and set desc "$token - $funcinfo[5]"
|
2020-07-12 03:13:47 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
case builtin
|
|
|
|
set desc (__fish_print_help $token | awk "/./ {print; exit}")
|
2019-10-06 21:14:10 +08:00
|
|
|
|
2020-07-12 03:19:37 +08:00
|
|
|
case file
|
|
|
|
set -l tmpdesc (whatis $token 2>/dev/null)
|
|
|
|
and set desc $tmpdesc
|
|
|
|
end
|
2020-07-12 02:53:25 +08:00
|
|
|
|
2024-04-11 18:34:58 +08:00
|
|
|
__fish_echo string join \n -- $desc
|
2019-10-06 21:14:10 +08:00
|
|
|
end
|