- make java completion aware of -jar

This commit is contained in:
ianmacd 2002-10-05 07:31:43 +00:00
parent b9a46e32db
commit d6089cccc2

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b # bash_completion - some programmable completion functions for bash 2.05b
# #
# $Id: bash_completion,v 1.424 2002/10/05 08:08:53 ianmacd Exp $ # $Id: bash_completion,v 1.425 2002/10/05 09:31:43 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -3055,15 +3055,32 @@ _java_packages()
cur=${COMPREPLY[@]//\//.} cur=${COMPREPLY[@]//\//.}
} }
# java # java completion
#
_java() _java()
{ {
local cur prev local cur prev i
COMPREPLY=() COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
for ((i=1; i < $COMP_CWORD; i++)); do
case ${COMP_WORDS[$i]} in
-cp|-classpath)
i++ # skip the classpath string.
;;
-*)
# this is an option, not a class/jarfile name.
;;
*)
# once we've seen a class, just do filename completion
_filedir
return 0
;;
esac
done
case $prev in case $prev in
-@(cp|classpath)) -@(cp|classpath))
_java_path _java_path
@ -3074,8 +3091,12 @@ _java()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
# relevant options completion # relevant options completion
COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \ COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \
-cp -classpath -D -verbose -version \ -cp -classpath -D -verbose -verbose:class \
-showversion -? -help -X -jar' -- $cur ) ) -verbose:gc -version:jni -version \
-showversion -? -help -X -jar \
-ea -enableassertions -da -disableassertions \
-esa -enablesystemassertions \
-dsa -disablesystemassertions ' -- $cur ) )
else else
if [[ "$prev" == -jar ]]; then if [[ "$prev" == -jar ]]; then
# jar file completion # jar file completion