From 0cdfab9bf6057f16f5540bda2bf19f82b44047fb Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 19 Nov 2012 10:45:53 +0100 Subject: [PATCH] Added autocomplete for "usemvn" function. --- plugins/available/maven.plugin.bash | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/available/maven.plugin.bash b/plugins/available/maven.plugin.bash index 2a1c5cbc..d09eaa9b 100644 --- a/plugins/available/maven.plugin.bash +++ b/plugins/available/maven.plugin.bash @@ -40,4 +40,29 @@ usemvn () fi export MAVEN_HOME=$MAVEN_INSTALL_ROOT/apache-maven-$1 fi -} \ No newline at end of file +} + +_usemvn-comp() +{ + local cur + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + + if [ -z "$MAVEN_INSTALL_ROOT" ] + then + local MAVEN_INSTALL_ROOT="/usr/local" + fi + + local mvn_versions=$(for i in $MAVEN_INSTALL_ROOT/apache-maven-* ; + do + if [ -x "$i/bin/mvn" ]; then + basename $i | sed 's/^apache-maven-//' + fi + done) + + COMPREPLY=( $(compgen -W "${mvn_versions}" -- ${cur}) ) + + return 0 +} + +complete -F _usemvn-comp usemvn