2019-10-06 07:14:10 -06: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 17:24:19 +05:30
|
|
|
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 07:14:10 -06:00
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
test -n "$token"
|
|
|
|
or return
|
2020-07-11 17:24:19 +05:30
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
set -l desc "$token: nothing appropriate."
|
2020-07-11 17:24:19 +05:30
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
set -l tokentype (type --type $token 2>/dev/null)
|
2020-07-11 17:24:19 +05:30
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
switch "$tokentype"
|
|
|
|
case function
|
|
|
|
set -l funcinfo (functions $token --details --verbose)
|
2020-07-11 17:24:19 +05:30
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
test $funcinfo[5] != n/a
|
|
|
|
and set desc "$token - $funcinfo[5]"
|
2020-07-12 00:43:47 +05:30
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
case builtin
|
|
|
|
set desc (__fish_print_help $token | awk "/./ {print; exit}")
|
2019-10-06 07:14:10 -06:00
|
|
|
|
2020-07-12 00:49:37 +05:30
|
|
|
case file
|
|
|
|
set -l tmpdesc (whatis $token 2>/dev/null)
|
|
|
|
and set desc $tmpdesc
|
|
|
|
end
|
2020-07-12 00:23:25 +05:30
|
|
|
|
2024-04-11 12:34:58 +02:00
|
|
|
__fish_echo string join \n -- $desc
|
2019-10-06 07:14:10 -06:00
|
|
|
end
|