Created
February 9, 2025 19:14
-
-
Save webbertakken/78ad5a15d7e8e2e140a9ee8ac62b8419 to your computer and use it in GitHub Desktop.
My PowerShell profile
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
# General modules | |
Import-Module -Name PSReadLine # typeahead predictions and whatnot | |
Import-Module -Name Terminal-Icons # Icons when listing directories | |
Import-Module -Name PSFzf # activate using `Ctrl T`, `Ctrl R` and `Alt C` | |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 # Exposes `refreshenv` | |
Invoke-Expression (&starship init powershell) | |
# Advanced completion features (arrow up and down after having started typing) | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | |
# Autocomplete suggestions | |
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete # options: [Complete|MenuComplete] | |
# Autocomplete predictions [HistoryAndPlugin, History, Plugin] requires PS 7.1+ | |
Set-PSReadLineOption -PredictionSource HistoryAndPlugin # accept prediction using right arrow | |
Set-PSReadLineOption -Colors @{ InlinePrediction = '#888888' } | |
# accepting suggestions | |
Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord # Accept one word | |
Set-PSReadLineKeyHandler -Chord "Ctrl+Spacebar" -Function ForwardChar # Accept full suggestion | |
############################################################ | |
# Support colors in tools that trigger on commit hooks # | |
############################################################ | |
$env:FORCE_COLOR = 1 | |
#################################### | |
# Support Linux commands # | |
#################################### | |
# Unix equivalent(ish) of `host` command. | |
function host { | |
param ($IpOrHostname) | |
$ErrorActionPreference = 'stop' | |
$Answer = Resolve-DnsName $IpOrHostname | |
Write-Output $Answer; | |
} | |
#################################### | |
# Functions # | |
#################################### | |
function Remove-LocalGitBranchesExceptMain { | |
git branch | ForEach-Object { | |
$_ = $_.Trim() | |
if ($_ -ne "main" -and $_ -ne "* main") { | |
git branch -D $_ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my PowerShell profile.
In PowerShell, type
code $PROFILE
to open it.If you're using my config, would you mind starring it? 🙂
Also, I'd be happy to take feedback and iterate on this.