Auto-complete to multiple possible file extensions

auto-completebash

(Edit: I suspect this was a better fit for the Unix and Linux stack exchange network — could someone migrate this over there? Or do I have to make an account over there myself?)

I'm converting some of my old terminal scripts (typically written in tcsh) to run as bash scripts in OSX. In particular, I'm trying to get my terminal to auto-complete inputs to certain programs specified by my .bash_profile settings. For example, the command

complete -f -X '!*.tex' emacs

correctly auto-completes emacs inputs only to .tex files. I was hoping something like this would work so that it would only tab-complete to .tex OR .txt files:

complete -f -X '!*.@(tex|txt)' emacs

But this fails. Any suggestions?

Best Answer

Cross referencing your answered cross post so future Googlers can find it
https://stackoverflow.com/questions/22854848/specifying-two-file-extensions-in-bash-complete