fish-shell/share/functions/__fish_whatis.fish
Mahmoud Al-Qudsi d914f4e991 Fix broken __fish_whatis
This has been broken for a *long* time.
2024-06-24 14:30:37 -05:00

20 lines
499 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 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