Add abook completion, based on work by Raphaël Droz.

master
Ville Skyttä 2009-10-29 20:29:35 +02:00
parent 884c3f5af6
commit 46fa5c464b
3 changed files with 68 additions and 2 deletions

View File

@ -18,7 +18,7 @@ bash-completion (2.x)
* Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist.
* Improve cvs, gkrellm, lftp, mdadm, and mysqladmin completions.
* Add wtf completion, based on work by Raphaël Droz.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add lftpget completion.
* Don't overwrite other host completions when completing from multiple
SSH known hosts files.

View File

@ -3,7 +3,8 @@ AUTOMAKE_OPTIONS = dist-bzip2
sysconf_DATA = bash_completion
bashcompdir = $(sysconfdir)/bash_completion.d
bashcomp_DATA = contrib/ant \
bashcomp_DATA = contrib/abook \
contrib/ant \
contrib/apache2ctl \
contrib/apt \
contrib/apt-build \

65
contrib/abook Normal file
View File

@ -0,0 +1,65 @@
# abook(1) completion
have abook &&
_abook()
{
local cur prev
COMPREPLY=()
cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
# abook only takes options, tabbing after command name adds a single
# dash (bash4)
[ ${BASH_VERSINFO[0]} -ge 4 -a $COMP_CWORD -eq 1 -a -z "$cur" ] &&
{
compopt -o nospace
COMPREPLY=( "-" )
return 0
}
case "$cur" in
-*)
_longopt abook
return 0
;;
esac
case "$prev" in
--informat)
[ ${BASH_VERSINFO[0]} -ge 4 ] && compopt +o filenames
COMPREPLY=( $( compgen -W "$(abook --formats | \
sed -n -e 's/^\t\([a-z]*\).*/\1/p' -e '/^$/q')" -- "$cur" ) )
return 0
;;
--outformat)
[ ${BASH_VERSINFO[0]} -ge 4 ] && compopt +o filenames
COMPREPLY=( $( compgen -W "$(abook --formats | \
sed -n -e '/^$/,$s/^\t\([a-z]*\).*/\1/p')" -- "$cur" ) )
return 0
;;
--infile)
COMPREPLY=( $( compgen -W stdin -- "$cur" ) )
_filedir
return 0
;;
--outfile)
COMPREPLY=( $( compgen -W stdout -- "$cur" ) )
_filedir
return 0
;;
--config|--datafile)
_filedir
return 0
;;
esac
} &&
complete -F _abook -o filenames abook
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh