Skip to content

Instantly share code, notes, and snippets.

@RoadToDream
Last active June 8, 2024 18:45
Show Gist options
  • Save RoadToDream/d799fb837596210174829b48c4c9a71f to your computer and use it in GitHub Desktop.
Save RoadToDream/d799fb837596210174829b48c4c9a71f to your computer and use it in GitHub Desktop.
PowerShell profile
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow BackwardWord
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow ForwardWord
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
$global:globalPromptInvokedCount = 0
Function prompt() {
if ($global:globalPromptInvokedCount -eq 0) {
$global:globalPromptInvokedCount++
$currentLocation = $executionContext.SessionState.Path.CurrentLocation.ToString()
$userHome = [Environment]::GetFolderPath("UserProfile")
if ($currentLocation -eq $userHome) {
$currentLocation = "~"
} else {
$currentLocation = Split-Path -Path $currentLocation -Leaf
}
$ESC = [char]27
"$ESC[38;2;227;100;100m@jduan $ESC[0m$ESC[38;2;98;237;139m➜ $ESC[0m$ESC[38;2;86;182;194m$currentLocation$ESC[0m "
} elseif ($global:globalPromptInvokedCount -eq 1) {
oh-my-posh init pwsh --config "C:\Users\jduan\AppData\Local\Programs\oh-my-posh\themes\zash_custom.omp.json" | Invoke-Expression
Import-Module posh-git
$global:globalPromptInvokedCount++
prompt
}
}
@RoadToDream
Copy link
Author

Hope this will help anyone who is also suffered from the loading time.
oh-my-posh takes a lot of time to load. #1624

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