Use _init_completion() in completions/a*.
This commit is contained in:
parent
ab29cef65a
commit
faf8ad159e
@ -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=( "-" )
|
||||
|
@ -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
|
||||
|
@ -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 "|" " ")
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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" ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user