diff --git a/completions/abook b/completions/abook index 37663b72..a7ba6f1e 100644 --- a/completions/abook +++ b/completions/abook @@ -4,14 +4,12 @@ have abook || return _abook() { - local cur prev - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return # abook only takes options, tabbing after command name adds a single # dash (bash4) - [[ ${BASH_VERSINFO[0]} -ge 4 && $COMP_CWORD -eq 1 && -z "$cur" ]] && + [[ ${BASH_VERSINFO[0]} -ge 4 && $cword -eq 1 && -z "$cur" ]] && { compopt -o nospace COMPREPLY=( "-" ) diff --git a/completions/ant b/completions/ant index 7102aceb..f4124293 100644 --- a/completions/ant +++ b/completions/ant @@ -4,10 +4,8 @@ have ant || return _ant() { - local cur prev buildfile i - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return case $prev in -buildfile|-file|-f) @@ -40,10 +38,10 @@ _ant() else # available targets completion # find which buildfile to use - buildfile=build.xml - for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == -@(?(build)file|f) ]]; then - buildfile=${COMP_WORDS[i+1]} + local buildfile=build.xml i + for (( i=1; i < cword; i++ )); do + if [[ "${words[i]}" == -@(?(build)file|f) ]]; then + buildfile=${words[i+1]} break fi done diff --git a/completions/apache2ctl b/completions/apache2ctl index 1a473f8b..7facbd2b 100644 --- a/completions/apache2ctl +++ b/completions/apache2ctl @@ -4,11 +4,10 @@ have apache2ctl || return _apache2ctl() { - local APWORDS cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return + local APWORDS APWORDS=$(apache2ctl 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ tr "|" " ") diff --git a/completions/apt b/completions/apt index 84811ae8..337de31b 100644 --- a/completions/apt +++ b/completions/apt @@ -3,14 +3,13 @@ have apt-get && _apt_get() { - local cur prev special i + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur prev - - for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do - if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then - special=${COMP_WORDS[i]} + local special i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then + special=${words[i]} fi done @@ -78,16 +77,15 @@ complete -F _apt_get apt-get have apt-cache && _apt_cache() { - local cur prev special i - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local special i if [ "$cur" != show ]; then - for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do - if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then - special=${COMP_WORDS[i]} - fi + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then + special=${words[i]} + fi done fi diff --git a/completions/apt-build b/completions/apt-build index 0f611e5c..5400dbb9 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -4,14 +4,13 @@ have apt-build || return _apt_build() { - local cur prev special i + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur prev - - for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do - if [[ ${COMP_WORDS[i]} == @(install|remove|source|info|clean) ]]; then - special=${COMP_WORDS[i]} + local special i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} == @(install|remove|source|info|clean) ]]; then + special=${words[i]} fi done diff --git a/completions/aptitude b/completions/aptitude index d66ed6eb..5ec8c618 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -17,11 +17,10 @@ _comp_dpkg_hold_packages() _aptitude() { - local cur dashoptions prev special i - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local dashoptions dashoptions='-S -u -i -h --help --version -s --simulate -d \ --download-only -P --prompt -y --assume-yes -F \ --display-format -O --sort -w --width -f -r -g \ @@ -29,13 +28,14 @@ _aptitude() --target-release -V --show-versions -D --show-deps\ -Z -v --verbose --purge-unused --schedule-only' - for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do - if [[ ${COMP_WORDS[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag) ]]; then - special=${COMP_WORDS[i]} + local special i + for (( i=0; i < ${#words[@]}-1; i++ )); do + if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag) ]]; then + special=${words[i]} fi #exclude some mutually exclusive options - [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i} - [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u} + [[ ${words[i]} == '-u' ]] && dashoptions=${dashoptions/-i} + [[ ${words[i]} == '-i' ]] && dashoptions=${dashoptions/-u} done if [[ -n "$special" ]]; then diff --git a/completions/aspell b/completions/aspell index 62c16d0c..17fadf32 100644 --- a/completions/aspell +++ b/completions/aspell @@ -17,11 +17,10 @@ _aspell_dictionary() _aspell() { - local cur prev split=false - - COMPREPLY=() - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local split=false _split_longopt && split=true case $prev in diff --git a/completions/autoconf b/completions/autoconf index c8f1b195..0eb2ca66 100644 --- a/completions/autoconf +++ b/completions/autoconf @@ -3,10 +3,10 @@ have autoconf && _autoconf() { - COMPREPLY=() - local cur prev split=false - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local split=false _split_longopt && split=true case "$prev" in diff --git a/completions/automake b/completions/automake index 7ed87453..1671d117 100644 --- a/completions/automake +++ b/completions/automake @@ -3,10 +3,10 @@ have automake && _automake() { - COMPREPLY=() - local cur prev split=false - _get_comp_words_by_ref cur prev + local cur prev words cword + _init_completion || return + local split=false _split_longopt && split=true case "$prev" in diff --git a/completions/autorpm b/completions/autorpm index 7f192210..dea2d484 100644 --- a/completions/autorpm +++ b/completions/autorpm @@ -4,10 +4,8 @@ have autorpm || return _autorpm() { - local cur - - COMPREPLY=() - _get_comp_words_by_ref cur + local cur prev words cword + _init_completion || return COMPREPLY=( $( compgen -W '--notty --debug --help --version auto add \ fullinfo info help install list remove set' -- "$cur" ) )