From 65a708cee0a4424f4e353d031ce440643e312f92 Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Mon, 8 Feb 2016 02:29:17 +0800 Subject: [PATCH] Allow bash-completion to work with full-path executable --- bash_completions.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bash_completions.go b/bash_completions.go index 131a59b7..eea11ee5 100644 --- a/bash_completions.go +++ b/bash_completions.go @@ -183,7 +183,11 @@ __handle_command() if [[ -n ${last_command} ]]; then next_command="_${last_command}_${words[c]//:/__}" else - next_command="_${words[c]//:/__}" + if [[ $c -eq 0 ]]; then + next_command="_$(basename ${words[c]//:/__})" + else + next_command="_${words[c]//:/__}" + fi fi c=$((c+1)) __debug "${FUNCNAME}: looking for ${next_command}" @@ -201,6 +205,8 @@ __handle_word() __handle_flag elif __contains_word "${words[c]}" "${commands[@]}"; then __handle_command + elif [[ $c -eq 0 ]] && __contains_word "$(basename ${words[c]})" "${commands[@]}"; then + __handle_command else __handle_noun fi