Bash (and with it Debian and Ubuntu and any number of other variants) has implemented numerous tab-completion extensions since the programmable tab-completion feature first appeared.
Annoyingly, quite possibly the worst implementation of this is for Perl.
The utterly basic version works as usual
adamk@red:~/stuff$ perl (tab)
blib/ Makefile script/ tmp/
Changes Makefile.PL .svn/
inc/ META.yml svn-commit.tmp
lib/ pm_to_blib t/
Of course, it doesn't show the Perl options. But you get that from this...
adamk@red:~/stuff$ perl -(tab)
-0 -c -d -e -h -I -m -n -P -S -u -v -w -x
-a -C -D -F -i -l -M -p -s -T -U -V -W -X
So now if you have no idea what the Perl options are called, but you know what they all do, you don't save a keystroke but you can get a reminder. hrm... vaaaaguely useful, ok.
Of course, having already chosen an option, like say to use the debugger, things go downhill..
adamk@red:~/stuff$ perl -d (tab)
adamk@red:~/stuff$ perl -d -
Wait... what?
The only thing I can possibly do after using a Perl option is, apparently, to add ANOTHER option to Perl... and there is no way to get tab completion for files after setting options.
This is utterly brain dead annoying.
Fortunately, a fix (although fiddly) exists.
In /etc/bash_completion, waaaaaaay down in the Perl section at line four bazillion and twelve, is this (hint: search in the file for the comment, it's about the second time it exists in the file, in a section called _perl)
# handle case where first parameter is not a dash option
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]]; then
This needs to be changed to this...
# handle case where first parameter is not a dash option
if [[ "$cur" != -* ]]; then
Thanks to Tony Cook for location the line to change, and writing the alternative.
Standard tab completion is one of the reasons I love zsh. If I do zsh -<Tab>
I get:
-I -- specify @INC/#include directory (may be used more than once)
-M -m -- module.. executes `use/no module...' before executing your script
-P -- run script through C preprocessor before compilation
-S -- look for the script using PATH environment variable
-T -- turn on tainted checks
-U -- allow unsafe operations
-V -- print perl configuration information
-a -- autosplit mode with -n or -p (splits $_ into @F)
-c -- check syntax only (runs BEGIN and END blocks)
...
Doing perldoc Catalyst::<Tab>
shows me all modules installed under that namespace.