Skip to content

Commit

Permalink
bash-completion: port to v2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-schwartz committed Jun 16, 2024
1 parent a61f178 commit eca81ee
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ag.bashcomp.sh
Original file line number Diff line number Diff line change
@@ -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='
Expand Down Expand Up @@ -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
Expand All @@ -117,7 +113,9 @@ _ag() {
return 0;;
esac

$split && return 0
if [[ ${split} = true ]]; then
return 0
fi

case "${cur}" in
-*)
Expand Down

0 comments on commit eca81ee

Please sign in to comment.