Skip to content

Commit

Permalink
✨ feat: add powershell completion for aws cli
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquindev committed Jan 11, 2025
1 parent 121c6a8 commit 93f6225
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dotposh/Config/posh-completions/aws.ps1
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
}

0 comments on commit 93f6225

Please sign in to comment.