Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
2  
Definitely a workaround only for vim, but if you are using NERDTree plugin, you might set up ignore rules in your .vimrc. stackoverflow.com/questions/5601749/… I wouldn't mind learning how to do the extension preference in shell too though. –  moon.musick Aug 5 '13 at 11:48
add comment

1 Answer 1

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 http://www.linuxjournal.com/content/more-using-bash-complete-command 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 at 18:32
add comment

Your Answer

 
discard

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.