forked from aaronpowell/ps-nvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocomplete-utils.ps1
17 lines (13 loc) · 970 Bytes
/
autocomplete-utils.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "")]
[CmdletBinding()]
param ()
$completion_AvailableNodeVersions = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
Get-NodeVersions | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', ('{0} ({1})' -f $_, $_)
}
}
if (-not (Test-Path variable:global:options)) { $global:options = @{CustomArgumentCompleters = @{};NativeArgumentCompleters = @{}}}
$global:options['CustomArgumentCompleters']['Remove-NodeVersion:Version'] = $completion_AvailableNodeVersions
$global:options['CustomArgumentCompleters']['Set-NodeVersion:Version'] = $completion_AvailableNodeVersions
$function:tabexpansion2 = $function:tabexpansion2 -replace 'End\r\n{','End { if ($null -ne $options) { $options += $global:options} else {$options = $global:options}'