Smarter Bash Tab Completion As a recent switcher from Ubuntu (Well recent switch backer if that's a word) I'm finding myself in the command line a lot more than when I was a mac user before. One thing I really loved about Ubuntu was when I was compiling and running java programs for class my tab completion was really smart. When I needed to compile my class if I had a directory that looked like:

Example.java
Example.class
Client.java
Client.class


and I needed to compile the Client.java to take into account the most recent changes I would type:

javac C [TAB]


and it would complete to 

javac Client.java


ignoring the .class files because you can't run javac on a .class. Also when I wanted to run the file typing

java C [TAB]


would result in

java Client


with no period. This was a very smart way of doing the tab completion that I got so used to that now it's driving me crazy when I hit tab and it gives me the Client. without actually completing to what I need it to be.

So is there any way to make the Mac bash completion smarter so that it would have this same effect?
*nix packages such as bash_completion can be installed with 3rd party package managers. I suggest Homebrew, but Fink and MacPorts also provide the bash_completion package. If it doesn't auto-handle the Java situation you describe, post back or read the man page.