Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

When using Maven (mvn) on OS X Terminal, how can I get tab-completion for Maven goals, plugin names, etc? Things like this:

mvn pa [TAB] -> mvn package

mvn je [TAB][TAB] -> mvn jetty:run
share|improve this question
    
I don't use maven, but is there not a bash-completion option on the Macports install? –  Clayton Stanley Apr 18 '13 at 7:04
    
@ClaytonStanley: Not sure, but I doubt it, since Maven default distribution doesn't come with it. I installed Maven with Homebrew; no bash-completion out of the box. –  Jonik Apr 18 '13 at 7:32

2 Answers 2

up vote 3 down vote accepted

Maven doesn't ship with an auto-complete script, but there's a project on GitHub called Maven Bash Completetion.

Installation if you use Homebrew:

  1. brew tap homebrew/completions
  2. brew install maven-completion

Otherwise, use this command to download the latest script (to your home directory as
~/.maven-completion.bash):

wget https://raw.github.com/juven/maven-bash-completion/master/bash_completion.bash -O ~/.maven-completion.bash

Then add this to your ~/.bash_profile:

if [ -f ~/.maven-completion.bash ]; then
  . ~/.maven-completion.bash
fi

You can also manually copy the file from the github repo to your home directory and edit your bash profile as above should the homebrew or wget options not work for you.

That's it. After you restart bash (e.g. open a new Terminal window), Maven autocomplete should work.

share|improve this answer

There was a missing s at the tap command. Should be

brew tap homebrew/completions
brew install maven-completion
share|improve this answer
1  
Useful correction but would be more useful if you edited the answer. I took care of it though –  StormeHawke Oct 28 at 18:19
    
@StormeHawke sorry, I thought I didn't have enough karma to do it –  Daniel Pinyol Oct 29 at 8:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.