2019-10-06 13:14:10 +00: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 11:54:19 +00: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 13:14:10 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
test -n "$token"
|
|
|
|
or return
|
2020-07-11 11:54:19 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
printf "\n"
|
|
|
|
set -l desc "$token: nothing appropriate."
|
2020-07-11 11:54:19 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
set -l tokentype (type --type $token 2>/dev/null)
|
2020-07-11 11:54:19 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
switch "$tokentype"
|
|
|
|
case function
|
|
|
|
set -l funcinfo (functions $token --details --verbose)
|
2020-07-11 11:54:19 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
test $funcinfo[5] != n/a
|
|
|
|
and set desc "$token - $funcinfo[5]"
|
2020-07-11 19:13:47 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
case builtin
|
|
|
|
set desc (__fish_print_help $token | awk "/./ {print; exit}")
|
2019-10-06 13:14:10 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
case file
|
|
|
|
set -l tmpdesc (whatis $token 2>/dev/null)
|
|
|
|
and set desc $tmpdesc
|
|
|
|
end
|
2020-07-11 18:53:25 +00:00
|
|
|
|
2020-07-11 19:19:37 +00:00
|
|
|
printf "%s\n" $desc
|
2019-10-06 13:14:10 +00:00
|
|
|
|
2022-04-09 20:06:06 +00:00
|
|
|
string repeat \n --count=(math (count (fish_prompt)) - 1)
|
2020-07-11 19:19:37 +00:00
|
|
|
|
|
|
|
commandline -f repaint
|
2019-10-06 13:14:10 +00:00
|
|
|
end
|