Show function description if available with whatis_current_token

By default __fish_whatis_current_token is bound to ALt-W
This commit is contained in:
Gokul Soumya 2020-07-11 17:24:19 +05:30 committed by Johannes Altmanninger
parent 1f8c9a5d42
commit d0ce5fe943

View file

@ -1,11 +1,25 @@
# This function is typically bound to Alt-W, it is used to list man page entries
# for the command under the cursor.
function __fish_whatis_current_token -d "Show man page entries related to the token under the cursor"
set -l tok (commandline -pt)
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)
if test -n "$tok[1]"
if test -n "$token"
printf "\n"
whatis $tok[1]
whatis $token 2>/dev/null
if test $status -eq 16 # no match found
set -l tokentype (type --type $token 2>/dev/null)
set -l desc ": nothing appropriate."
if test "$tokentype" = "function"
set -l funcinfo (functions $token --details --verbose)
test $funcinfo[5] != "n/a"
and set desc " - $funcinfo[5]"
end
printf "%s%s\n" $token $desc
end
set -l line_count (count (fish_prompt))
# Ensure line_count is greater than one to accomodate different