Skip to content

Instantly share code, notes, and snippets.

@finesse-fingers
Last active December 10, 2021 23:43
Show Gist options
  • Save finesse-fingers/62f0a4ed4887efbbe0ef8d1dd668dd23 to your computer and use it in GitHub Desktop.
Save finesse-fingers/62f0a4ed4887efbbe0ef8d1dd668dd23 to your computer and use it in GitHub Desktop.
Pretty themes and history autocompletion for Powershell in Windows Terminal

How to pimp Powershell

Install posh-git, oh-my-posh and CaskaydiaCode Nerd Font

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Visit https://www.nerdfonts.com/ and find CaskaydiaCove Nerd Font. The font contains glyphs/icons required by the themes.

Now open Powershell profile and configure it:

code $PROFILE

Paste the following:

# https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
# https://ohmyposh.dev/docs/themes
# Install-Module posh-git -Scope CurrentUser
# Install-Module oh-my-posh -Scope CurrentUser

Import-Module posh-git
Import-Module oh-my-posh

# Themes require a font with glyphs (recommended Caskaydia Cove Nerd Font)
# Download fonts from https://www.nerdfonts.com/
# Install the theme once downloaded and set fontFace as such in Windows Terminal:
# {
#     "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
#     "hidden": false,
#     "name": "PowerShell",
#     "source": "Windows.Terminal.PowershellCore",
#     "fontFace":  "CaskaydiaCove Nerd Font"
# },
# Set the integrated terminal font in VSC and restart:
# {
#     ...
#     "terminal.integrated.fontFamily": "CaskaydiaCove Nerd Font"
#     ...
# }

# Get-PoshThemes
Set-PoshPrompt -Theme aliens

# https://github.com/PowerShell/PSReadLine
Import-Module PSReadLine

# Shows navigable menu of all options when hitting Tab
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

# Autocompletion for Arrow keys
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

# Predictive suggestions based on history
Set-PSReadLineOption -ShowToolTips
Set-PSReadLineOption -PredictionSource History

To list the available themes, run:

Get-PoshThemes

Removing “username@host” from prompt

Navigate to ~\Documents\PowerShell\Modules\oh-my-posh\3.175.0\themes copy, rename and modify the desired theme by removing the session segment.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment