Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have noticed sometimes that tab completion is helpfully filtered in bash. I am a java programmer and often use the java and javac commands in the terminal for quick or remote tasks.

Say I have the two usual files in a directory: and MyProgram.class

If I ask bash to tabcomplete from the command prefix java M, it fills straight out to java MyProgram, this is helpful. Clearly either bash is configured to only accept *.class completions for the java command (and knows to strip the file extension), or the java command is telling bash this somehow.

I would like to accomplish the same with a text editor, so I could type in nano M and have it tab complete to nano rather than pausing at nano MyProgram., is it possible to say, blacklist *.class from nano's tab complete?

Most of all I'd just be interested to know if this is a bash configuration or something program-side.

share|improve this question
up vote 3 down vote accepted

java has a separate auto-completion script that overrides the default completion mechanism. On my distribution (Arch Linux), it is installed in /usr/share/bash-completion/completions/java.

To override the behaviour of tab-completion, you could create such a script. If you just want to have all .class files ignored for every command, you could set the FIGNORE variable (e.g. in your ~/.bashrc). Example: FIGNORE=.class. From the manual page of bash:

A colon-separated list of suffixes to ignore when performing filename completion (see READLINE below). A filename whose suffix matches one of the entries in FIGNORE is excluded from the list of matched filenames. A sample value is ".o:~".

share|improve this answer
ahh that's what i was looking for, many thanks – lynks Aug 29 '12 at 11:22

Your Answer


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.