Created
May 14, 2015 00:19
-
-
Save nzbart/27248a01b43cb0000994 to your computer and use it in GitHub Desktop.
Chain a PowerShell script block to the tabexpansion2 function, calling the original implementation if the new one doesn't return a result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Add-TabExpansion | |
{ | |
param([ScriptBlock][parameter(mandatory)]$ScriptBlock) | |
$originalFunction = (gcm TabExpansion2).ScriptBlock | |
$chainedBlock = { | |
$userResult = & $ScriptBlock @Args | |
if($userResult) { | |
return $userResult | |
} | |
return & $originalFunction @Args | |
}.GetNewClosure() | |
Set-Content Function:\TabExpansion2 $chainedBlock | |
} | |
Add-TabExpansion @Args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment