I’m not a bash guru by any stretch…
With bash, you can use programmable completion to define functions that control how expansion is done for specific commands, but I don’t think you can redefine how the default kinds of completion are done, short of modifying the bash source code.
This leaves you with a few options. You could define a custom completion function, and then try to associate with all of the commands you commonly use. That strikes me as an ugly solution; even if you eventually get the function associated with nearly all of the commands you use, you’re still going to trip over commands for which completion doesn’t work from time to time. How annoying.
You could define a single command, which does nothing more than execute the command it receives as arguments. Now you’ve got only that one command to associate with the completion function, but everything you do for which you want this completion to work is going to look like “runmycmd ls blahblahblah.” Yuck.
Or, give up on doing something bash specific, and just write a simple shell script to handle the expansion. Something like:
#!/bin/sh
find /$1 -name \*$2 -print
Name it something short, say “q”, and now you can do “q foo 1234” to see an expansion of /foo/bar/baz/quux1234, and things like "ls q foo 1234
" to feed the expansion as an argument to other commands. Not exactly what you wanted, but it may be less annoying than any of the options for doing what you really wanted. And it’s not bash-specific, so your tcsh users are happy too.
I suppose you could also do a mix of the last two, and associate the completion function with echo. Then you could do stuff like "ls echo foo1234<tab>
" That would have the advantage of letting you see the expansion before you hit return.
If you’re still going to go down the custom completion route, you may want to check out the bash man page under “Programmable Completion,” and perhaps check out the completion definitions that come with subversion as an example of how to get it to work.