This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
PowerShell Tab Completion is since RC1 customizable,
you can look at the current implementation like this :
get-content function:TabExpansionThis is my first customization to this function :
I added Tab-completion for Types to get the static methods (and properties)
I like this especialy becouse normaly you have to remember to use get-member - static to list them.
This also works for Enums :
[regex]::M [tab]
[regex]::Match(
[dateTime]:: [tab]
[datetime]::Compare(
[consolecolor]::B [tab]
[consolecolor]::Black [tab]
[consolecolor]::Blue [tab]
[consolecolor]::Black
the Code I added looks like this :
function tabexpansion {
# (Original Code Here )
switch -regex ($lastWord)
{
# this Part is added to handle Types
# /\/\o\/\/ 2006
# Handle Types
'(\[.*\])::(\w*)' {
invoke-expression "$($matches[1]) | gm -static" | where {$_.name -like "$($matches[2])*"} |% {
if ($_.MemberType -band $method) {
"$($matches[1])::$($_.name)" + '('
} Else {
"$($matches[1])::$($_.name)"
}
}
}
# End of added Part
# Handle property and method expansion...
# (Original Code Here )
}
*Note* if you output the original code to a file (gc function:TabExpansion | out-file) you will miss the line "Function {" and the last "}" you need to add it to declare the function again.
then below the Switch statement (I left in in for readability, you add the custom code.
you need to . source the script to overwrite the $global tabExpansion function.
and put it in your profile to use it every session.
Enjoy,
gr /\/\o\/\/
Tags : Monad msh PowerShell