Speaking of little happy making things

When, exactly, did bash become smart enough to handle command completion for sub-commands? I noticed this today on my Ubuntu (Dapper) box. I, unintentionally1, typed hg <tab><tab>. Rather than getting the “Display all 100 possibilities? (y or n)” I expected, I got

add         copy        hgext/hgk]  manifest    rawcommit   tag
addremove   cp          history     [module     recover     tags
annotate    ct          id          mv          remove      tip
bundle      diff        identify    out         rename      unbundle
cat         export      import      outgoing    revert      undo
checkout    forget      in          parents     rm          up
ci          grep        incoming    patch       root        update
clone       heads       init        paths       serve       verify
co          help        locate      pull        st          version
commit      hgext/hct]  log         push        status      view
pwilliams@pwilliams:~$ hg 

Which is the list all the valid sub-commands for hg. And if I do hg<br /> d<tab> it auto-completes the sub-command to hg diff. Same thing for cvs and apt-get. It seems that bash now support full auto-completion of sub-commands for most programs2.

That is just cool.


  1. I unconsciously double tap the tab key whenever I stop typing because I am addicted to auto-complete and Emacs contextually correct indentation.

    </li>

  2. It does not work for gem, though.

    </li> </ol> </div>