From ac4f8710babeda6d1dbdd7fccbb952af376eff33 Mon Sep 17 00:00:00 2001 From: Maor Kadosh Date: Sun, 14 Jul 2024 16:10:20 +0300 Subject: [PATCH] Batman unalias --- src/batman.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/batman.sh b/src/batman.sh index e8af7a2..7842a7c 100755 --- a/src/batman.sh +++ b/src/batman.sh @@ -92,13 +92,21 @@ if [[ "${#MAN_ARGS[@]}" -eq 0 ]] && [[ -z "$BATMAN_LEVEL" ]] && command -v "$EXE if [[ -z "$selected_page" ]]; then exit 0 fi + + # Some entries from `man -k .` may include "synonyms" of a man page's title. + # For example, the manual for kubectl-edit will appear as: + # + # kubectl-edit(1), kubectl edit(1) - Edit a resource on the server + # + # `man` only needs one name/title, so we're taking the first one here. + selected_page_unaliased="$(echo "$selected_page" | cut -d, -f1)" # Convert the page(section) format to something that can be fed to the man command. while read -r line; do if [[ "$line" =~ ^(.*)\(([0-9a-zA-Z ]+)\) ]]; then MAN_ARGS+=("${BASH_REMATCH[2]}" "$(echo ${BASH_REMATCH[1]} | xargs)") fi - done <<< "$selected_page" + done <<< "$selected_page_unaliased" fi # Run man.