Last active
November 29, 2022 16:25
-
-
Save Adam--/809cafe28772dd25428d14e937d2c30e to your computer and use it in GitHub Desktop.
Loads tools I use in the PowerShell prompt
This file contains 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
function RunStep([string] $Description, [ScriptBlock]$script) | |
{ | |
Write-Host -NoNewline "Loading" $Description.PadRight(20) | |
& $script | |
Write-Host "✓" # checkmark emoji | |
} | |
RunStep "posh-git" { | |
# Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names. | |
# https://github.com/dahlbyk/posh-git | |
# https://www.powershellgallery.com/packages/posh-git/ | |
Import-Module posh-git | |
# Adds a newline to the prompt before the suffix to make the prompt look somthing like this: | |
# C:\Path\ | |
# > _ | |
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`n' | |
} | |
RunStep "autocomplete" { | |
# Shows navigable menu of all options when hitting Tab | |
# https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlinekeyhandler | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
# Shows predictive completion. Accept results using the right arrow key. | |
# https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption#-predictionsource | |
Set-PSReadLineOption -PredictionSource History | |
# Search history using up and down arrow keys, enter to execute | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
# No sounds | |
Set-PSReadlineOption -BellStyle None | |
} | |
RunStep "z" { | |
# z lets you quickly navigate the file system in PowerShell based on your cd command history. It's a port of the z bash shell script | |
# https://github.com/badmotorfinger/z | |
# https://www.powershellgallery.com/packages/z/ | |
Import-Module z | |
} | |
RunStep "open-solution" { | |
# Quickly open solutions using sln and atsln | |
Import-Module open-solution | |
} | |
RunStep "chocolatey" { | |
# Import the Chocolatey Profile that contains the necessary code to enable | |
# tab-completions to function for `choco`. | |
# Be aware that if you are missing these lines from your profile, tab completion | |
# for `choco` will not function. | |
# See https://ch0.co/tab-completion for details. | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment