Bash: fix man apropos functionality

This commit is contained in:
Akemi Izuko 2024-08-31 20:05:17 -06:00
parent 0d83b26079
commit 397e891010
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC

View file

@ -66,6 +66,7 @@ sww() {
# Proper manpages =================================================== # Proper manpages ===================================================
man() { man() {
local command=$(IFS=-, ; echo "$*") local command=$(IFS=-, ; echo "$*")
local -r man="$(which man | tail -n1)"
# When section is specified,override # When section is specified,override
if [[ "$1" =~ ^[1-7]$ ]]; then if [[ "$1" =~ ^[1-7]$ ]]; then
@ -74,7 +75,10 @@ man() {
shift shift
command=$(IFS=-, ; echo "$*") command=$(IFS=-, ; echo "$*")
/usr/bin/man "$section" "$command" "$man" "$section" "$command"
return $?
elif [[ "$1" == -k ]]; then
"$man" -k "$(IFS=-; echo "${*:2}")"
return $? return $?
fi fi
@ -83,7 +87,7 @@ man() {
if [[ "$command" =~ \. ]] && "$manpy" "$command" &>/dev/null; then if [[ "$command" =~ \. ]] && "$manpy" "$command" &>/dev/null; then
"$manpy" "$command" "$manpy" "$command"
elif /usr/bin/man "$command" >/dev/null 2>&1; then elif /usr/bin/man "$command" >/dev/null 2>&1; then
/usr/bin/man "$command" "$man" "$command"
elif command -v "$command" &>/dev/null; then elif command -v "$command" &>/dev/null; then
"$command" --help | nvim -R -c 'set syn=man' -- "$command" --help | nvim -R -c 'set syn=man' --
elif command -v "$@" &>/dev/null; then elif command -v "$@" &>/dev/null; then