Created
November 29, 2022 02:28
-
-
Save peterneave/d400f6eedeb9c027ffaa41d2785c5d01 to your computer and use it in GitHub Desktop.
Powershell Profile
This file contains hidden or 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
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