Skip to content

Instantly share code, notes, and snippets.

@Nuclearfossil
Last active December 6, 2022 18:41
Show Gist options
  • Save Nuclearfossil/3a4125f970c96759522997f9b79e783b to your computer and use it in GitHub Desktop.
Save Nuclearfossil/3a4125f970c96759522997f9b79e783b to your computer and use it in GitHub Desktop.
My current Powershell startup script
# To edit this file, in powershell type: `code $profile`
#
# If you need to remove/update PSReadline, you'll need to remove the module
# from your powershell modules folder. You'll need to close all powershell instances
# and delete the `PSReadline` module folder manuall before you install it with
# `Install-Module PSReadline`.
# after that, you should be good.
#
# To install starship on powershell, from the Admin command line, enter
# scoop install starship
# Install the Terminal-Icons module
if (-not(Get-Module -ListAvailable -Name Terminal-Icons))
{
Install-Module -Name Terminal-Icons -Repository PSGallery
}
# Add the module import to your PowerShell profile
Import-Module -Name Terminal-Icons
# PowerShell Readline options
Import-Module PSReadLine
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key Alt+d -Function KillWord
# PowerShell Readline options
Set-PSReadLineOption -HistoryNoDuplicates
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -MaximumHistoryCount 2000
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally
Set-PSReadLineOption -Colors @{ InlinePrediction = '#9CA3AF'}
# Setup for Posh-git
$env:POSH_GIT_ENABLED=$true
Import-Module posh-git
# some powershell functions
function clean
{
git clean -ffxd
}
function .. {Set-Location ..}
function ... {Set-Location ..\..}
function google
{
$query = 'https://www.google.com/search?q='
$args | % { "q=" + "$_ "}
$url = $query + [System.Web.HttpUtility]::UrlEncode($args)
start "$url"
}
function so
{
$query = 'http://stackoverflow.com/search?q='
$args | % { "q=" + "$_ "}
$url = $query + [System.Web.HttpUtility]::UrlEncode($args)
start "$url"
}
# Some oh-my-posh theme candidates
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/kushal.omp.json" | Invoke-Expression
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/.omp.json" | Invoke-Expression
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jandedobbeleer.omp.json" | Invoke-Expression
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/powerlevel10k_modern.omp.json" | Invoke-Expression
#oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/velvet.omp.json" | Invoke-Expression
# And finally, Starship prompt settings
$ENV:STARSHIP_CONFIG = "$HOME\.config\starship.toml"
Invoke-Expression (&starship init powershell)
@Nuclearfossil
Copy link
Author

link to my starship.toml file

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