Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

If I have multiple files all with the same name (except, of course, the extension), is there a way of making bash auto-complete to a specific extension when I open them from the terminal with a text editor?

In particular, I am using latex with vim, and upon compiling one gets log files, aux files etc, and so I need to first type vim w, auto-complete to vim work., then put in another t and auto-complete to vim work.tex. It seems like there should be a way of telling bash to got straight to the tex file.

I imagine this is not going to be vim specific, but I am not 100%, so I have left the tag in.

share|improve this question
Definitely a workaround only for vim, but if you are using NERDTree plugin, you might set up ignore rules in your .vimrc.… I wouldn't mind learning how to do the extension preference in shell too though. – moon.musick Aug 5 '13 at 11:48
up vote 1 down vote accepted

A simple but coarse solution is to set the FIGNORE environment variable to a colon-separated list of extensions to be ignored during tab completion. This may already do the job for you.

If you want certain file types to be ignored only for specific commands, you will need to write a completion function for that command. The HOWTO at will get you on your way.

share|improve this answer
Hi, I don't logon that often, and since your answer was a little while after I asked I have only just seen it. Thank you though, that is very useful. – Joe Tait May 23 '14 at 18:32

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.