-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add powershell completion for aws cli
- Loading branch information
1 parent
121c6a8
commit 93f6225
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if (Get-Command aws -ErrorAction SilentlyContinue) { | ||
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action { | ||
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-completion.html | ||
Register-ArgumentCompleter -Native -CommandName aws -ScriptBlock { | ||
param($commandName, $wordToComplete, $cursorPosition) | ||
$env:COMP_LINE = $wordToComplete | ||
if ($env:COMP_LINE.Length -lt $cursorPosition) { | ||
$env:COMP_LINE = $env:COMP_LINE + " " | ||
} | ||
$env:COMP_POINT = $cursorPosition | ||
aws_completer.exe | ForEach-Object { | ||
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | ||
} | ||
Remove-Item Env:\COMP_LINE | ||
Remove-Item Env:\COMP_POINT | ||
} | ||
} | Out-Null | ||
} |