2018-06-27 19:11:57 +00:00
|
|
|
# uses `whatis` if available to describe a command
|
|
|
|
|
|
|
|
function __fish_whatis
|
2019-05-05 10:09:25 +00:00
|
|
|
set -l cmd $argv[1]
|
|
|
|
set -l fallback
|
|
|
|
if set -q argv[2]
|
|
|
|
set fallback $argv[2]
|
|
|
|
end
|
2018-06-27 19:11:57 +00:00
|
|
|
|
2019-05-05 10:09:25 +00:00
|
|
|
set -l description (whatis $cmd 2>/dev/null | string replace -r '.*? - ' '')[1]
|
2024-06-24 19:25:17 +00:00
|
|
|
if string match -qr -- "." "$description"
|
2019-05-05 10:09:25 +00:00
|
|
|
printf '%s\n' $description
|
|
|
|
return 0
|
|
|
|
else if not string match -q -- "$fallback" ""
|
|
|
|
printf '%s\n' $fallback
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
end
|
2018-06-27 19:11:57 +00:00
|
|
|
end
|