Over a million developers have joined DZone.

Bash Completion for Maven

DZone's Guide to

Bash Completion for Maven

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

Based on a blog post by John Hitchings on the WealthFront Engineering web site, I started looking into bash completion.

As a Java developer, I use Maven from the command-line quite a bit, so I decided to add bash completion for the ‘mvn’ command.

The following script works great on OS X, and should work in bash on other systems as well.

Happy completion!

local cur prev opts
opts="clean compile package install"

if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" ${cur}) )
return 0
complete -F _mvn mvn

From http://greybeardedgeek.net/2011/02/bash-completion-for-maven/

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}