0

I have a slight pet peeve when I try to compile and run my java programs in the terminal

javac example.java

When I want to run java example and use autocomplete on the java command, it automatically includes the period (java example.). Of course, this is standard behavior as it matches the longest prefix, but is there a way to cut off the trailing period here? I wouldn't mind editing certain configuration files and I believe I saw other computers slicing off the period. It would be especially nice if this functionality is exclusive to the terminal command java.

Dici
  • 25,226
  • 7
  • 41
  • 82
Abundance
  • 1,963
  • 3
  • 24
  • 46
  • I thought it would complete to example.class , did you turn off extensions on your computer? – SomeDude Dec 29 '15 at 00:23
  • well, there is example.java and example.class, so example. makes sense. This is on bash version 3.2.57(1) – Abundance Dec 29 '15 at 00:24
  • 1
    I don't know if you already have seen http://unix.stackexchange.com/questions/4738/an-easy-bash-completion-tutorial – SomeDude Dec 29 '15 at 00:29
  • If the autocompletion information linked in svasa's comment works, that seems like the right answer. If not, you could try `touch example` to create a dummy file in that directory, which should fool bash without causing any other problems (hopefully). – ajb Dec 29 '15 at 00:43

1 Answers1

0

As comments stated, the answer was to use bash-completion. I used the following git-repo as a reference. As for my case on a Mac (taken straight from the link), the instructions are as follows:

brew install bash-completion

and inside ~/.bash_profile, the following lines are added:

if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
Abundance
  • 1,963
  • 3
  • 24
  • 46