fish-shell/share/functions/__fish_whatis.fish
Johannes Altmanninger 9c327b19a6 Fix extra or missing newlines at end of file in our fish scripts
New fish_indent does that too, so this will make any future reformatting
diffs smaller.

Done using either of:

	perl -pi -e 'undef $/; s/\n*$/\n/' share/**.fish
	kak -n -f '<a-/>\n*<ret>d' share/**.fish
2020-08-09 23:53:46 +02:00

20 lines
503 B
Fish

# uses `whatis` if available to describe a command
function __fish_whatis
set -l cmd $argv[1]
set -l fallback
if set -q argv[2]
set fallback $argv[2]
end
set -l description (whatis $cmd 2>/dev/null | string replace -r '.*? - ' '')[1]
if not string match -qr -- "." "$description"
printf '%s\n' $description
return 0
else if not string match -q -- "$fallback" ""
printf '%s\n' $fallback
return 0
else
return 1
end
end