Skip to content

Commit

Permalink
Handle colon in bash comp v2
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
  • Loading branch information
marckhouzam committed Jul 12, 2020
1 parent 2cfa836 commit bef15e5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bash_completionsV2.go
Expand Up @@ -199,14 +199,30 @@ __%[1]s_perform_completion()
COMPREPLY+=("$comp")
fi
fi
__%[1]s_handle_special_char "$cur" :
__%[1]s_handle_special_char "$cur" =
}
__%[1]s_handle_special_char()
{
local comp="$1"
local char=$2
if [[ "$comp" == *${char}* && "$COMP_WORDBREAKS" == *${char}* ]]; then
local word=${comp%%"${comp##*${char}}"}
local idx=${#COMPREPLY[*]}
while [[ $((--idx)) -ge 0 ]]; do
COMPREPLY[$idx]=${COMPREPLY[$idx]#"$word"}
done
fi
}
__start_%[1]s()
{
local cur prev words cword
COMPREPLY=()
_get_comp_words_by_ref -n = cur prev words cword
_get_comp_words_by_ref -n "=:" cur prev words cword
__%[1]s_perform_completion
}
Expand Down

0 comments on commit bef15e5

Please sign in to comment.