Last active
February 19, 2022 07:31
-
-
Save ArmaanMcleod/e5198a35ce99fdb8c3bb06f87679e3e4 to your computer and use it in GitHub Desktop.
Oh my posh PowerShell Profile Windows
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
#Requires -Modules Terminal-Icons | |
#Requires -Modules posh-git | |
#Requires -Modules PSReadline | |
#Requires -Modules DockerCompletion | |
# Init Oh My Posh with config | |
oh-my-posh --init --shell pwsh --config "${env:USERPROFILE}\ohmyposhv3-2.json" | Invoke-Expression | |
# Import icons, Posh GIT, Docker completion and PSReadLine | |
Import-Module Terminal-Icons | |
Import-Module posh-git | |
Import-Module PSReadline | |
Import-Module DockerCompletion | |
# Set PSReadline options | |
Set-PSReadLineOption -EditMode Windows | |
Set-PSReadLineOption -PredictionViewStyle ListView | |
Set-PSReadLineOption -PredictionSource History | |
# PowerShell parameter completion shim for the dotnet CLI | |
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock { | |
param($commandName, $wordToComplete, $cursorPosition) | |
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object { | |
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
} | |
} | |
# PowerShell parameter completion shim for the winget CLI | |
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', $_) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment