views:

12

answers:

1

The tabexpansion function only works partially when I override it like so:

function tabexpansion {
    param($line, $lastWord)

    if ($line -eq "hey ") {
        "you", "Joe"
    }
}

The custom completions work as expected, but now I only get the default autocomplete behavior for cmdlet names, not parameters. So New-TAB works fine, but New-Alias -TAB doesn't. How do I get the regular completions too after overriding tabexpansion?

+1  A: 

The file name and cmdlet expansion is handled in the shell itself if the function doesn't do anything on those. Everything else, including static members, parameters to cmdlets, &c. is handled by the function. If you take a look at Function:TabExpansion there is quite a bit going on there you may want to keep if you want the other tab completion features to still work.

Joey