Skip to content

Instantly share code, notes, and snippets.

@RaminMT
Last active November 19, 2021 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaminMT/36021603eb5f6cdabc94aadad4172c75 to your computer and use it in GitHub Desktop.
Save RaminMT/36021603eb5f6cdabc94aadad4172c75 to your computer and use it in GitHub Desktop.
My powershell profile
##### CaskaydiaCove Nerd Font (https://www.nerdfonts.com/font-downloads)
##### PSReadLine (https://github.com/PowerShell/PSReadLine)
# https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/
# Install-Module -Name PSReadLine ||||| For stable versions
# Install-Module -Name PSReadLine -AllowPrerelease -Force ||||| For pre release versions
Import-Module -Name PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineKeyHandler -Key Tab -Function Complete
# Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
# Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
##### Terminal Icons (https://github.com/devblackops/Terminal-Icons)
# Install-Module -Name Terminal-Icons -Repository PSGallery
Import-Module -Name Terminal-Icons
##### Z (https://github.com/badmotorfinger/z)
# Install-Module -Name z -AllowClobber
Import-Module -Name z
##### OhMyPosh (https://ohmyposh.dev)
# winget install JanDeDobbeleer.OhMyPosh
oh-my-posh --init --shell pwsh --config ~\AppData\Local\Programs\oh-my-posh\themes\raminmt.json | Invoke-Expression
##### Code compeletions
### dotnet
# 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', $_)
}
}
### 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', $_)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment