From 397e891010f2fc8e9a33dce13e83a6812a34d8af Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sat, 31 Aug 2024 20:05:17 -0600 Subject: [PATCH] Bash: fix man apropos functionality --- bash/.bash_functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash/.bash_functions b/bash/.bash_functions index 0073039..526d606 100644 --- a/bash/.bash_functions +++ b/bash/.bash_functions @@ -66,6 +66,7 @@ sww() { # Proper manpages =================================================== man() { local command=$(IFS=-, ; echo "$*") + local -r man="$(which man | tail -n1)" # When section is specified,override if [[ "$1" =~ ^[1-7]$ ]]; then @@ -74,7 +75,10 @@ man() { shift command=$(IFS=-, ; echo "$*") - /usr/bin/man "$section" "$command" + "$man" "$section" "$command" + return $? + elif [[ "$1" == -k ]]; then + "$man" -k "$(IFS=-; echo "${*:2}")" return $? fi @@ -83,7 +87,7 @@ man() { if [[ "$command" =~ \. ]] && "$manpy" "$command" &>/dev/null; then "$manpy" "$command" elif /usr/bin/man "$command" >/dev/null 2>&1; then - /usr/bin/man "$command" + "$man" "$command" elif command -v "$command" &>/dev/null; then "$command" --help | nvim -R -c 'set syn=man' -- elif command -v "$@" &>/dev/null; then