Tuesday, August 25, 2009

Bash Completion + Java

I think the title says it all, I was just checking something at work and needed to run one of our Java apps using the command line, I did the standard:
java -cp jarfile1.jar:jarfile2.jar au.gov.


and hit tab key twice out of habit and to my surprise bash had checked the jar files inside the command I was writing and presented me with all the class options!!

Bash auto completion just continues to impress me! Thank you bash, you have just made my life SO much easier yet again.

For those of you who have no idea what bash is, its a terminal shell used by default in Linux.. so for those of you out there not yet using Linux, here is yet another reason to do so.

OSX also uses bash as the default shell for the terminal, so I'll now have to test it on my macbook.. after a quick test the answer is no, OSX is either using an older version of bash which doesn't support this feature, or hasn't turned on/set up all the autocompletion features by default.

2 Comments:

Blogger oerd said...

This comment has been removed by the author.

7:56 am  
Blogger oerd said...

You obviously need to source bash_completion, so it can work its magic ;)

The problem with OSX seems to be with the right path.

I recommend installing through Macports and sourcing bash_completion from macports:

if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi

8:02 am  

Post a Comment

<< Home