Welcome to MSDN Blogs Sign in | Join | Help

Tab Completion

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

Published Thursday, January 31, 2008 12:38 AM by PowerShellTeam

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Tab Completion

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!!! =)

Thursday, January 31, 2008 2:43 AM by Alexander Trofimov

# PoSh'лые маски и автозавершение по кнопке табуляции...

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

Thursday, January 31, 2008 4:12 AM by ИТ, ИБ и т.п.

# re: Tab Completion

> 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

Thursday, January 31, 2008 11:30 AM by PowerShellTeam

# re: Tab Completion

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?

Friday, February 01, 2008 12:34 AM by ALexander Trofimov

# re: Tab Completion

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

Thursday, February 14, 2008 9:16 AM by EDF

# re: tab completion

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,?,%,...).

Monday, February 18, 2008 11:50 AM by ales zelinka

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker