Created
January 13, 2023 22:06
-
-
Save sheldonhull/0fff516d6190c50da62b9b2da0bb55fb to your computer and use it in GitHub Desktop.
super simple powershell profile improvement with starship
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
# This should go into the $PROFILE file. Open in code easily with `code $PROFILE` in a powershell terminal. | |
if (-not (Get-InstalledModule PSReadline -ErrorAction SilentlyContinue)) { | |
Install-Module PSReadline -Force -Confirm:$false -Scope CurrentUser -AllowPrerelease | |
} | |
if (-not (Get-Module PSReadline)) { | |
Import-Module PSReadline -DisableNameChecking -Global -Force | |
} | |
Set-PSReadLineOption -EditMode Windows | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | |
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete | |
Set-PSReadLineKeyHandler -Key Ctrl+C -Function Copy | |
Set-PSReadLineKeyHandler -Key Ctrl+v -Function Paste | |
Set-PSReadLineKeyHandler -Key Alt+Backspace -Function ShellKillWord | |
Set-PSReadLineOption -PredictionViewStyle ListView # As of 2020-11 only supported with editmode windows https://bit.ly/3lMEKN4 | |
Set-PSReadLineOption -PredictionSource History | |
if ((Get-Command 'starship' -ErrorAction SilentlyContinue).Count -eq 0) { | |
Write-Warning "missing starship so setting up for you" | |
choco install starship -y | |
} | |
Invoke-Expression (@(&starship init powershell --print-full-init) -join "`n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment