# Friday, August 24, 2007

While I absolutely love MoW's PowerTab, there's been one little niggling thing that's been missing since day one; while you can navigate Types using the opening square bracket syntax, e.g. [<tab> , when using the new-object command this method is not totally syntactically compatible. (update: MoW explains in a comment below that there is a special trick for navigating without the square brackets, oops! me wrong!) You have to navigate to your type, then edit out the square brackets which is a little bit annoying. Also, when using this syntax you typically know exactly which type you need but can't remember the namespace. Or perhaps you know the type name, but don't want to have to type it all out (or navigate there).

So, I figured I'd crack open PowerTab and see how easy it was to implement. To cut a long story short, in about 30 minutes it was done. The thing that made it so easy was that MoW already has a DataSet in memory of all types and their namespaces, so the grunt work is done by a simple DataTable.Select call. I modified the function TabExpansion in TabExpansion.ps1 (version 0.96 b12), and put the following snippet just after the switch on $lastWord :

switch -regex ($lastWord) {

    # Handle inline type search, e.g. new-object .identityreference<tab> or .identityre<tab>
    '^\.(\w+)$' {
       
$typeName = $matches[1]
      
$types = $dsTabexpansion.tables["Types"]
       
$rowFilter = "name like '%.${typeName}%'"
       $types.select($rowFilter) | % {$_["name"] } | Invoke-TabItemSelector $lastWord -Select $SelectionHandler
       break;
    }

The type search is initiated by prefixing the full or partial type name with a period (.) and then hitting tab. There you have it, inline type search. Have fun!

Saturday, August 25, 2007 8:04:58 AM (Eastern Daylight Time, UTC-04:00)
Oisin,

an alternative build in allready is using = [tab] after the typename []
Powertab will transfor it into a new-object command
e.g.

[regex]=[tab]
new-Object regex

this does no wildcard search, but you can do one using the utilty scripts.

get-tabExpansion *ident* types

But I like this a lot,
I added it to the new 0.97 version , main link is still version 0.96 but you can find the 0.97 pre-release on the beta page allready :

http://thepowershellguy.com/blogs/posh/pages/powertab-beta.aspx

Thanks,

Greetings /\/\o\/\/

/\/\o\/\/
Saturday, August 25, 2007 11:07:07 AM (Eastern Daylight Time, UTC-04:00)
Thanks MoW, silly me. I've updated the entry.
Oisin
Comments are closed.