Tab Completion

Tab Completion

  • Comments 6

Did you realize that you can use Wildcards with our tab completion?

At the very beginning of the project, we had long discussions about whether it should be "Verb-Noun" or "Noun-Verb".  One of the arguments for NOUN-VERB was that it was better for tab completion.  We expected a TON of nouns but only a few verbs.  As such, if you type VERB-<TAB>, you'd see a ton of things to choose from.   Alternatively, if you typed NOUN-<TAB>, you'd only see the VERBS that apply to that noun. 

That wasn't a good enough reason to go NOUN-VERB.  In the end, we wanted a THINK-TYPE-GET system and VERB-NOUN makes command sequences read like English:

Get-Process |where {$_.handles -ge 500} |sort handles |format-table name,handles

So what about tab completion - are you just hosed?  NOPE.

PowerShell's tab completion supports wildcards.  Try it yourself:

*-Pro<TAB>
*-p<Tab>
*-p*er<TAB>

 

All that said, I would be remiss if I didn't point you to MOW's excellent replacement for our tab completion called PowerTab.  You can get it HERE.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 3 and 7 and type the answer here:
  • Post
  • Great! Though last example doesn't work exectly I want. For example the first cmdlet it shows me is Get-PfxCertificate which doesn't end with "er".

    But it's great!!! =)

  • Громкий заголовок получился. Прямо как я люблю =)Возвращаясь к теме, поясню: я начинаю тихо фанатеть...

  • > Great! Though last example doesn't work exectly I want. For example the first cmdlet it shows me is Get-PfxCertificate which doesn't end with "er".

    I was a little surprised by that as well but if you think about it in the context of tabcompletion, it makes sense.  When you tab complete, you implicitly add a "*" to the end.

    Jeffrey Snover [MSFT]

    Windows Management Partner Architect

    Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell

    Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

  • Oh... I'm sorry, that's my fault - I wasn't too attentive =(

    It works great in that case too =)

    Is there a possibility to receive a commandlet which ends with "er", for example?

  • This is one of the simple powershell tips that I haven't seen anyone else cover.  Thanks!

  • As for the tab-completion: Thanks for the tip on wildcard tabbing.

    Now I wonder, is there a way to make tab completion work on aliases? Becouse I don't like the read-like-english syntax (too bloated), so I only use aliases and short versions of the most common cmdlets and language elements (ps,ls,kill,?,%,...).

Page 1 of 1 (6 items)