Skip to content

Instantly share code, notes, and snippets.

@peterneave
Created November 29, 2022 02:28
Show Gist options
  • Save peterneave/d400f6eedeb9c027ffaa41d2785c5d01 to your computer and use it in GitHub Desktop.
Save peterneave/d400f6eedeb9c027ffaa41d2785c5d01 to your computer and use it in GitHub Desktop.
Powershell Profile
Import-Module PSReadLine
Import-Module Posh-Git
oh-my-posh init pwsh --config '$env:UserProfile\jandedobbeleer.omp.json' | Invoke-Expression
# AWS CLI
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
}
# winget
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# dotnet
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment