diff --git a/ag.bashcomp.sh b/ag.bashcomp.sh index 5637ce44..e03f580e 100644 --- a/ag.bashcomp.sh +++ b/ag.bashcomp.sh @@ -1,11 +1,9 @@ _ag() { - local lngopt shtopt split=false - local cur prev + local cur prev words cword split + local lngopt shtopt COMPREPLY=() - cur=$(_get_cword "=") - prev="${COMP_WORDS[COMP_CWORD-1]}" - + _init_completion -s || return 0 _expand || return 0 lngopt=' @@ -96,12 +94,10 @@ _ag() { types=$(ag --list-file-types |grep -- '--') # these options require an argument - if [[ "${prev}" == -[ABCGgm] ]] ; then + if [[ "${prev}" = -[ABCGgm] ]] ; then return 0 fi - _split_longopt && split=true - case "${prev}" in --ignore-dir) # directory completion _filedir -d @@ -117,7 +113,9 @@ _ag() { return 0;; esac - $split && return 0 + if [[ ${split} = true ]]; then + return 0 + fi case "${cur}" in -*)