Skip to content

Instantly share code, notes, and snippets.

@gowon
Last active February 20, 2025 08:08
Show Gist options
  • Save gowon/49800552ce330a801f2723d2e103c253 to your computer and use it in GitHub Desktop.
Save gowon/49800552ce330a801f2723d2e103c253 to your computer and use it in GitHub Desktop.
Custom PowerShell Profile

Custom PowerShell Profile

Instructions

  1. Install Windows Terminal, PowerShell 7+, Oh My Posh (using Chocolatey)

    choco install oh-my-posh
  2. Install Nerd Font

    oh-my-posh font install meslo
  3. Configure Windows Terminal to use your Nerd Font by going to Settings -> Profiles: Defaults -> Appearance -> Font face

  4. Install PS Module dependencies

    Install-Module -Name Terminal-Icons -Repository PSGallery
  5. Edit your PowerShell profile script (Microsoft.PowerShell_profile.ps1) and replace with gist file:

    code $PROFILE
  6. Reload your profile for the changes to take effect.

    . $PROFILE
  7. Profit 🔥

# ref: https://github.com/PowerShell/PSReadLine
# ref: https://github.com/devblackops/Terminal-Icons
Import-Module -Name PSReadLine,Terminal-Icons
# Add Predictive IntelliSense using prompt history in a list view
# ref: https://www.hanselman.com/blog/adding-predictive-intellisense-to-my-windows-terminal-powershell-prompt-with-psreadline
# ref: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
# PowerShell parameter completion shim for the dotnet CLI
# ref: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#powershell
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
dotnet complete --position $cursorPosition "$commandAst" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
# ref: https://ohmyposh.dev/docs
# favorite themes: night-owl, thecyberden, unicorn
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/night-owl.omp.json" | Invoke-Expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment