diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-01-04 19:07:30 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-01-04 19:07:30 +0200 |
commit | bda497eb58b0ec2a3385dab98ee42b3221f4e1ee (patch) | |
tree | 76ba7a757e4cf4acbdce788683bd70868e2f6088 | |
parent | 6c21f884567783be204174fa970b677aa5923cb2 (diff) | |
download | bash-completion-bda497eb58b0ec2a3385dab98ee42b3221f4e1ee.tar.gz |
Add bunch of java option completions, improve colon handling.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | completions/java | 89 |
2 files changed, 79 insertions, 12 deletions
@@ -15,7 +15,7 @@ bash-completion (2.x) * Add *.gif (Alioth: #312512), *.m2t (Alioth: #312770), *.3gpp, *.3gpp2, *.awb, and *.iso (Alioth: #311420) to mplayer filename completions. * Add "short" tarball extensions to unxz, unlzma etc completions. - * Improve /etc/init.d/*, ipmitool, jar, javadoc, man, mencoder, mkdir, + * Improve /etc/init.d/*, ipmitool, jar, java, javadoc, man, mencoder, mkdir, mplayer, povray, python, rpmbuild, sqlite3, tar, wodim, and general help parsing completions. * Fix p4 and povray completions (Alioth: #312625). diff --git a/completions/java b/completions/java index fcdc5723..8365a314 100644 --- a/completions/java +++ b/completions/java @@ -118,13 +118,13 @@ _java_packages() # _java() { - local cur prev i + local cur prev words cword i COMPREPLY=() - _get_comp_words_by_ref cur prev + _get_comp_words_by_ref -n : cur prev words cword - for ((i=1; i < $COMP_CWORD; i++)); do - case ${COMP_WORDS[$i]} in + for ((i=1; i < $cword; i++)); do + case ${words[$i]} in -cp|-classpath) ((i++)) # skip the classpath string. ;; @@ -139,6 +139,70 @@ _java() esac done + case $cur in + # standard option completions + -verbose:*) + COMPREPLY=( $( compgen -W 'class gc jni' -- "${cur#*:}" ) ) + return 0 + ;; + -javaagent:*) + cur=${cur#*:} + _filedir '@(jar|zip)' + return 0 + ;; + -agentpath:*) + cur=${cur#*:} + _filedir so + return 0 + ;; + # various non-standard option completions + -splash:*) + cur=${cur#*:} + _filedir '@(gif|jp?(e)g|png)' + return 0 + ;; + -Xbootclasspath*:*) + _java_path + return 0 + ;; + -Xcheck:*) + COMPREPLY=( $( compgen -W 'jni' -- "${cur#*:}" ) ) + return 0 + ;; + -Xgc:*) + COMPREPLY=( $( compgen -W 'singlecon gencon singlepar genpar' \ + -- "${cur#*:}" ) ) + return 0 + ;; + -Xgcprio:*) + COMPREPLY=( $( compgen -W 'throughput pausetime deterministic' \ + -- "${cur#*:}" ) ) + return 0 + ;; + -Xloggc:*|-Xverboselog:*) + cur=${cur#*:} + _filedir + return 0 + ;; + -Xshare:*) + COMPREPLY=( $( compgen -W 'auto off on' -- "${cur#*:}" ) ) + return 0 + ;; + -Xverbose:*) + COMPREPLY=( $( compgen -W 'memory load jni cpuinfo codegen opt + gcpause gcreport' -- "${cur#*:}" ) ) + return 0 + ;; + -Xverify:*) + COMPREPLY=( $( compgen -W 'all none remote' -- "${cur#*:}" ) ) + return 0 + ;; + # the rest that we have no completions for + -D*|-*:*) + return 0 + ;; + esac + case $prev in -cp|-classpath) _java_path @@ -147,13 +211,11 @@ _java() esac if [[ "$cur" == -* ]]; then - # relevant options completion - COMPREPLY=( $( compgen -W '-client -hotspot -server -classic \ - -classpath -D -verbose -verbose:class \ - -verbose:gc -version:jni -version \ - -showversion -help -X -jar \ - -enableassertions -disableassertions \ - -enablesystemassertions -disablesystemassertions ' -- "$cur" ) ) + # standard options + COMPREPLY=( $( compgen -W '-client -server -agentlib: -agentpath: + -classpath -D -d32 -d64 -enableassertions -disableassertions + -enablesystemassertions -disablesystemassertions -jar -javaagent: + -verbose -verbose -version -showversion -help -X' -- "$cur" ) ) else if [[ "$prev" == -jar ]]; then # jar file completion @@ -163,6 +225,11 @@ _java() _java_classes fi fi + + [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == -*[:=] ]] && \ + type compopt &>/dev/null && compopt -o nospace + + __ltrim_colon_completions "$cur" } complete -F _java java } |